Bound ffmpeg video encoder threads

This commit is contained in:
Victor Kuznetsov
2026-07-31 14:33:50 -07:00
parent 7fb0e65455
commit 166dab9d03
5 changed files with 22 additions and 42 deletions
+5 -10
View File
@@ -1950,17 +1950,19 @@ class TestVideoVisibleScan:
class TestVideoVisibleEncoding:
def test_raw_pipe_input_disables_redundant_ffmpeg_probing(
@pytest.mark.parametrize("suffix", [".mp4", ".webm"])
def test_encoder_bounds_codec_threads(
self,
tmp_path: Path,
monkeypatch: pytest.MonkeyPatch,
suffix: str,
):
from remove_ai_watermarks import video_encoding
monkeypatch.setattr(video_encoding.shutil, "which", lambda _name: "/usr/bin/ffmpeg")
command = video_encoding.raw_video_command(
tmp_path / "source.mp4",
tmp_path / "clean.mp4",
tmp_path / f"clean{suffix}",
width=12,
height=8,
fps=24.0,
@@ -1969,14 +1971,7 @@ class TestVideoVisibleEncoding:
profile=video_encoding.VideoEncodeProfile(),
)
pipe_position = command.index("pipe:0")
assert command[pipe_position - 5 : pipe_position] == [
"-analyzeduration",
"0",
"-probesize",
"32",
"-i",
]
assert command[command.index("-threads:v") + 1] == "2"
@staticmethod
def _patch_single_frame_encode(
+1 -5
View File
@@ -102,13 +102,9 @@ def test_timestamped_encoder_reads_nut_and_passes_pts_through(
)
assert "-copyts" in command
assert command[command.index("-f") : command.index("-f") + 8] == [
assert command[command.index("-f") : command.index("-f") + 4] == [
"-f",
"nut",
"-analyzeduration",
"0",
"-probesize",
"32",
"-i",
"pipe:0",
]