Skip to content

Commit bb20812

Browse files
NVergunst-ROBONicholas Vergunst
authored andcommitted
ENT-1686: Set FFmpeg stimeout and timeout independently
A legacy env with only stimeout would skip timeout, which FFmpeg 5+ actually uses. Fill whichever key is missing.
1 parent e047088 commit bb20812

2 files changed

Lines changed: 14 additions & 2 deletions

File tree

inference/core/interfaces/camera/rtsp_opencv_tls.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,9 +99,10 @@ def build_opencv_ffmpeg_capture_options(video: Union[str, int]) -> Optional[str]
9999
merged = _parse_opencv_ffmpeg_capture_options(existing or "")
100100
for key, value in overrides.items():
101101
merged[key] = value
102-
if "stimeout" not in merged and "timeout" not in merged:
103-
timeout_value = str(_RTSPS_OPEN_TIMEOUT_US)
102+
timeout_value = str(_RTSPS_OPEN_TIMEOUT_US)
103+
if "stimeout" not in merged:
104104
merged["stimeout"] = timeout_value
105+
if "timeout" not in merged:
105106
merged["timeout"] = timeout_value
106107
return _format_opencv_ffmpeg_capture_options(merged)
107108

tests/inference/unit_tests/core/interfaces/camera/test_rtsp_opencv_tls.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,10 +96,21 @@ def test_build_options_merges_existing_env(
9696
got = build_opencv_ffmpeg_capture_options("rtsps://cam/stream")
9797
assert got is not None
9898
assert "stimeout;5000000" in got
99+
assert "timeout;5000000" in got
99100
assert "rtsp_transport;tcp" in got
100101
assert "tls_verify;1" in got
101102

102103

104+
def test_build_options_fills_stimeout_when_only_timeout_present(
105+
monkeypatch: pytest.MonkeyPatch,
106+
) -> None:
107+
monkeypatch.setenv(OPENCV_FFMPEG_CAPTURE_OPTIONS_ENV_VAR, "timeout;5000000")
108+
got = build_opencv_ffmpeg_capture_options("rtsps://cam/stream")
109+
assert got is not None
110+
assert "stimeout;5000000" in got
111+
assert "timeout;5000000" in got
112+
113+
103114
def test_rtsp_tls_validation_flags_gstreamer_suffix(
104115
monkeypatch: pytest.MonkeyPatch,
105116
) -> None:

0 commit comments

Comments
 (0)