feat: add stream-copy exports

This commit is contained in:
2026-08-16 09:29:47 +02:00
parent 8f354254b2
commit d5d74066b0
6 changed files with 264 additions and 47 deletions
+34
View File
@@ -18,6 +18,10 @@ def test_build_export_path_sub():
assert build_export_path("/out", "clip", 1, sub=0) == "/out/clip_001_0.mp4"
assert build_export_path("/out", "clip", 1, sub=2) == "/out/clip_001_2.mp4"
def test_build_export_path_custom_extension():
assert build_export_path("/out", "clip", 1, sub=0, extension=".mkv") == "/out/clip_001_0.mkv"
assert build_export_path("/out", "clip", 1, extension="mov") == "/out/clip_001.mov"
def test_build_sequence_dir_sub():
assert build_sequence_dir("/out", "clip", 1, sub=0) == "/out/clip_001_0"
assert build_sequence_dir("/out", "clip", 1, sub=1) == "/out/clip_001_1"
@@ -54,6 +58,36 @@ def test_ffmpeg_command_with_resize():
assert "scale" in vf_value
assert cmd[-1] == "/out/clip_001.mp4"
def test_ffmpeg_command_stream_copy():
cmd = build_ffmpeg_command(
"/in/video.mkv", 12.5, "/out/clip_001.mkv",
duration=3600.0, stream_copy=True,
)
assert cmd[cmd.index("-ss") + 1] == "12.5"
assert cmd[cmd.index("-t") + 1] == "3600.0"
assert cmd.index("-ss") < cmd.index("-i")
assert "-copyts" in cmd
assert "-start_at_zero" in cmd
assert cmd[cmd.index("-c") + 1] == "copy"
assert "-c:v" not in cmd
assert "-c:a" not in cmd
assert cmd[-1] == "/out/clip_001.mkv"
def test_ffmpeg_command_stream_copy_rejects_transforms():
import pytest
with pytest.raises(ValueError, match="Stream copy"):
build_ffmpeg_command(
"/in/video.mkv", 0.0, "/out/clip.mkv",
short_side=256, stream_copy=True,
)
def test_ffmpeg_command_stream_copy_mp4_uses_normal_timestamp_rebasing():
cmd = build_ffmpeg_command(
"/in/video.mp4", 12.5, "/out/clip.mp4", stream_copy=True,
)
assert "-copyts" not in cmd
assert "-start_at_zero" not in cmd
def test_audio_clip_command_exact_length():
cmd = build_audio_clip_command("/in/video.mp4", 12.5, 3.2, "/out/clip.wav")