Prevent ffmpeg pipe probe deadlock

This commit is contained in:
Victor Kuznetsov
2026-07-31 12:05:42 -07:00
parent f9a4e2ba10
commit 1fd859b58d
4 changed files with 49 additions and 4 deletions
+28
View File
@@ -1950,6 +1950,34 @@ class TestVideoVisibleScan:
class TestVideoVisibleEncoding:
def test_raw_pipe_input_disables_redundant_ffmpeg_probing(
self,
tmp_path: Path,
monkeypatch: pytest.MonkeyPatch,
):
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",
width=12,
height=8,
fps=24.0,
strip_metadata=True,
crf=14,
profile=video_encoding.VideoEncodeProfile(),
)
pipe_position = command.index("pipe:0")
assert command[pipe_position - 5 : pipe_position] == [
"-analyzeduration",
"0",
"-probesize",
"32",
"-i",
]
@staticmethod
def _patch_single_frame_encode(
monkeypatch: pytest.MonkeyPatch,
+10 -1
View File
@@ -102,7 +102,16 @@ def test_timestamped_encoder_reads_nut_and_passes_pts_through(
)
assert "-copyts" in command
assert command[command.index("-f") : command.index("-f") + 4] == ["-f", "nut", "-i", "pipe:0"]
assert command[command.index("-f") : command.index("-f") + 8] == [
"-f",
"nut",
"-analyzeduration",
"0",
"-probesize",
"32",
"-i",
"pipe:0",
]
assert command[command.index("-fps_mode") + 1] == "passthrough"
assert command[command.index("-avoid_negative_ts") + 1] == "disabled"
assert command[command.index("-enc_time_base:v") + 1] == "1/90000"