feat(v1): configurable low-latency capture options

Config gains source.transport (tcp/udp), timeout_seconds and low_latency;
build_ffmpeg_options assembles OPENCV_FFMPEG_CAPTURE_OPTIONS and app.py
sets it into the environment before opening the stream, so tuning lives
in config/settings instead of a launch script. Settings tab exposes a
dropdown/number/checkbox rather than the raw option string. 64 tests pass.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
ila
2026-07-21 22:56:14 +08:00
co-authored by Claude Opus 4.8
parent 5e4068db17
commit 1471e7ce78
9 changed files with 143 additions and 7 deletions
+53 -1
View File
@@ -2,7 +2,7 @@ import json
import pytest
from v1.config import ConfigError, load_config
from v1.config import ConfigError, build_ffmpeg_options, load_config
def _write_config(path, source):
@@ -140,6 +140,58 @@ def test_public_example_config_has_no_embedded_credentials():
assert "rtsp_url_env" in source
def test_build_ffmpeg_options_variants():
assert build_ffmpeg_options() == "rtsp_transport;tcp|stimeout;5000000|fflags;nobuffer|flags;low_delay"
assert build_ffmpeg_options("udp", 3, False) == "rtsp_transport;udp|stimeout;3000000"
with pytest.raises(ValueError):
build_ffmpeg_options("http")
def test_source_capture_tuning_defaults_to_tcp_low_latency(tmp_path):
config_file = tmp_path / "config.json"
_write_config(
config_file,
{"id": "c", "host": "192.0.2.10", "username": "u", "password": "p"},
)
config = load_config(config_file)
assert config.transport == "tcp"
assert config.timeout_seconds == 5.0
assert config.low_latency is True
assert (
config.ffmpeg_capture_options
== "rtsp_transport;tcp|stimeout;5000000|fflags;nobuffer|flags;low_delay"
)
def test_source_capture_tuning_is_parsed(tmp_path):
config_file = tmp_path / "config.json"
_write_config(
config_file,
{
"id": "c", "host": "192.0.2.10", "username": "u", "password": "p",
"transport": "udp", "timeout_seconds": 3, "low_latency": False,
},
)
config = load_config(config_file)
assert config.transport == "udp"
assert config.ffmpeg_capture_options == "rtsp_transport;udp|stimeout;3000000"
def test_invalid_transport_is_rejected(tmp_path):
config_file = tmp_path / "config.json"
_write_config(
config_file,
{"id": "c", "host": "192.0.2.10", "username": "u", "password": "p", "transport": "http"},
)
with pytest.raises(ConfigError, match="transport"):
load_config(config_file)
def test_source_mode_defaults_to_stream(tmp_path, monkeypatch):
config_file = tmp_path / "config.json"
_write_config(