From 9d2cb13b9c60bcb0f424371a74cee567bb77cda1 Mon Sep 17 00:00:00 2001 From: Erwin Douna Date: Wed, 30 Sep 2026 09:40:31 +0200 Subject: [PATCH] Generate stream test frames as uint8 (#183689) --- tests/components/stream/common.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/tests/components/stream/common.py b/tests/components/stream/common.py index 1cc9201c0228..4a419f7dcae5 100644 --- a/tests/components/stream/common.py +++ b/tests/components/stream/common.py @@ -53,13 +53,13 @@ def generate_audio_frame(pcm_mulaw=False): @functools.lru_cache(maxsize=1024) def frame_image_data(frame_i, total_frames): """Generate image content for a frame of a video.""" - img = np.empty((480, 320, 3)) - img[:, :, 0] = 0.5 + 0.5 * np.sin(2 * np.pi * (0 / 3 + frame_i / total_frames)) - img[:, :, 1] = 0.5 + 0.5 * np.sin(2 * np.pi * (1 / 3 + frame_i / total_frames)) - img[:, :, 2] = 0.5 + 0.5 * np.sin(2 * np.pi * (2 / 3 + frame_i / total_frames)) - - img = np.round(255 * img).astype(np.uint8) - return np.clip(img, 0, 255) + color = [ + np.round( + 255 * (0.5 + 0.5 * np.sin(2 * np.pi * (c / 3 + frame_i / total_frames))) + ) + for c in range(3) + ] + return np.full((480, 320, 3), color, dtype=np.uint8) def generate_video(encoder, container_format, duration):