Skip to content

Clone your own voice on your own computer: speak any text in 60+ languages and dub videos into another language in your voice. Fully local. Early version.

fix: write a video with a picture with square pixels (#169)

Mykola Bezrukyi0d54aa9dc38b
diff --git a/engine/src/mimvox_engine/videoexport.py b/engine/src/mimvox_engine/videoexport.py
index a73f01c..2a54c59 100644
--- a/engine/src/mimvox_engine/videoexport.py
+++ b/engine/src/mimvox_engine/videoexport.py
@@ -299,7 +299,7 @@ def composite_command(exe: str | Path, src: str | Path, dst: str | Path) -> list
graph = (
f"[0:v]split[a][b];[a]scale=384:216,gblur=sigma=10,scale={WIDTH}:{HEIGHT}[bg];"
f"[b]scale={WIDTH}:{HEIGHT}:force_original_aspect_ratio=decrease:force_divisible_by=2[fg];"
- "[bg][fg]overlay=(W-w)/2:(H-h)/2,format=yuv420p[v]"
+ "[bg][fg]overlay=(W-w)/2:(H-h)/2,setsar=1,format=yuv420p[v]"
)
out = ["-map", "[v]", "-frames:v", "1", *_STILL, dst]
return [exe, "-nostdin", "-v", "error", "-y", "-i", src, "-filter_complex", graph, *out]
diff --git a/engine/tests/test_video_export.py b/engine/tests/test_video_export.py
index a3b00e3..07dedd6 100644
--- a/engine/tests/test_video_export.py
+++ b/engine/tests/test_video_export.py
@@ -466,6 +466,19 @@ def test_recorded_segments_win_and_custom_starts(tmp_path, clip):
assert picture_and_length(dest) == (True, pytest.approx(1.5, abs=0.1))
+@needs_x264
+def test_a_tall_picture_keeps_square_pixels(tmp_path, clip):
+ dest = tmp_path / "tall.mp4"
+ images = [{"path": str(tmp_path / "tall.jpg")}]
+ event, data = export(Ctx(tmp_path), path=str(clip), dest=str(dest), format="mp4", images=images)
+ assert event == "video.done", data
+ shape = ["-select_streams", "v:0", "-show_entries", "stream=width,height,sample_aspect_ratio", "-of", "csv=p=0"]
+ probed = subprocess.run(
+ [str(media.ffprobe_path()), "-v", "error", *shape, str(dest)], capture_output=True, text=True, check=True
+ )
+ assert probed.stdout.strip() == f"{videoexport.WIDTH},{videoexport.HEIGHT},1:1"
+
+
@needs_x264
def test_photos_fade_in_and_into_each_other(tmp_path, clip):
ff("-f", "lavfi", "-i", "color=c=white:s=64x48", "-frames:v", "1", tmp_path / "white.png")