Skip to content

Local UI to run and train LLMs and diffusion models. Supports GGUF, MLX, Qwen3.8, DeepSeek-V4.1, MiniMax-H3, Gemma 4, FLUX and more.

Studio: keep every frame when downloading a video as WebM (#17239)

Nilay4657301a83ac
diff --git a/studio/backend/core/inference/video_gallery.py b/studio/backend/core/inference/video_gallery.py
index d2c8faf96a8..3ab89c8bc67 100644
--- a/studio/backend/core/inference/video_gallery.py
+++ b/studio/backend/core/inference/video_gallery.py
@@ -425,8 +425,6 @@ def _transcode_webm(path: Path, dest: Path) -> None:
# demux both streams together so the muxer sees them interleaved rather than buffering every video packet
for packet in src.demux(*([in_v] + ([in_a] if out_a is not None else []))):
- if packet.dts is None:
- continue
if packet.stream is in_v:
for frame in packet.decode():
for out_packet in out_v.encode(frame.reformat(format = "yuv420p")):
diff --git a/studio/backend/tests/test_video_gallery.py b/studio/backend/tests/test_video_gallery.py
index 190211b2f9f..a43af6e2da3 100644
--- a/studio/backend/tests/test_video_gallery.py
+++ b/studio/backend/tests/test_video_gallery.py
@@ -320,6 +320,7 @@ def _real_mp4_bytes(
frames: int = 8,
size: int | tuple[int, int] = 32,
rate: int = 8,
+ codec: str = "mpeg4",
) -> bytes:
av = pytest.importorskip("av")
np = pytest.importorskip("numpy")
@@ -327,7 +328,7 @@ def _real_mp4_bytes(
buf = io.BytesIO()
with av.open(buf, "w", format = "mp4") as out:
- stream = out.add_stream("mpeg4", rate = rate)
+ stream = out.add_stream(codec, rate = rate)
width, height = size if isinstance(size, tuple) else (size, size)
stream.width = width
stream.height = height
@@ -477,6 +478,16 @@ def test_transcode_gif_and_webm_produce_real_containers():
assert webm is not None and webm[:4] == b"\x1a\x45\xdf\xa3"
+def test_webm_export_keeps_every_frame_of_an_h264_clip():
+ av = pytest.importorskip("av")
+ import io
+
+ record = gallery.save(_real_mp4_bytes(frames = 25, codec = "libx264"), _meta())
+ webm = gallery.transcode(record["id"], "webm")
+ with av.open(io.BytesIO(webm)) as container:
+ assert sum(1 for _ in container.decode(video = 0)) == 25
+
+
def test_thumbnail_produces_a_webp_from_the_video():
import io