From 592141daaa7fe8d79fa04d54f90db723d4d4f8b1 Mon Sep 17 00:00:00 2001 From: Josh Hawkins <32435876+hawkeye217@users.noreply.github.com> Date: Mon, 21 Apr 2025 07:38:51 -0500 Subject: [PATCH] Increase ffmpeg timeout to 10 seconds (#17831) FFmpeg adds an extra delay for the first start of the stream. For some cameras the stream start can be 1 second, for some cameras it can be more than 5 seconds. Frigate by default used a timeout of 5 seconds and drops the connection without waiting for a response from go2rtc. Originally suggested by @AlexxIT in https://github.com/AlexxIT/go2rtc/issues/1633 --- .../main/rootfs/usr/local/go2rtc/create_config.py | 2 +- frigate/ffmpeg_presets.py | 14 +++++++------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/docker/main/rootfs/usr/local/go2rtc/create_config.py b/docker/main/rootfs/usr/local/go2rtc/create_config.py index ac44f1fe4..dc136b611 100644 --- a/docker/main/rootfs/usr/local/go2rtc/create_config.py +++ b/docker/main/rootfs/usr/local/go2rtc/create_config.py @@ -102,7 +102,7 @@ elif go2rtc_config["ffmpeg"].get("bin") is None: # need to replace ffmpeg command when using ffmpeg4 if LIBAVFORMAT_VERSION_MAJOR < 59: - rtsp_args = "-fflags nobuffer -flags low_delay -stimeout 5000000 -user_agent go2rtc/ffmpeg -rtsp_transport tcp -i {input}" + rtsp_args = "-fflags nobuffer -flags low_delay -stimeout 10000000 -user_agent go2rtc/ffmpeg -rtsp_transport tcp -i {input}" if go2rtc_config.get("ffmpeg") is None: go2rtc_config["ffmpeg"] = {"rtsp": rtsp_args} elif go2rtc_config["ffmpeg"].get("rtsp") is None: diff --git a/frigate/ffmpeg_presets.py b/frigate/ffmpeg_presets.py index 3c251b3b7..77b96057b 100644 --- a/frigate/ffmpeg_presets.py +++ b/frigate/ffmpeg_presets.py @@ -283,7 +283,7 @@ PRESETS_INPUT = { "-probesize", "1000M", "-rw_timeout", - "5000000", + "10000000", ], "preset-rtmp-generic": [ "-avoid_negative_ts", @@ -297,7 +297,7 @@ PRESETS_INPUT = { "-fflags", "+genpts+discardcorrupt", "-rw_timeout", - "5000000", + "10000000", "-use_wallclock_as_timestamps", "1", "-f", @@ -312,7 +312,7 @@ PRESETS_INPUT = { "-rtsp_transport", "tcp", TIMEOUT_PARAM, - "5000000", + "10000000", "-use_wallclock_as_timestamps", "1", ], @@ -321,14 +321,14 @@ PRESETS_INPUT = { "-rtsp_transport", "tcp", TIMEOUT_PARAM, - "5000000", + "10000000", ], "preset-rtsp-restream-low-latency": _user_agent_args + [ "-rtsp_transport", "tcp", TIMEOUT_PARAM, - "5000000", + "10000000", "-fflags", "nobuffer", "-flags", @@ -343,7 +343,7 @@ PRESETS_INPUT = { "-rtsp_transport", "udp", TIMEOUT_PARAM, - "5000000", + "10000000", "-use_wallclock_as_timestamps", "1", ], @@ -362,7 +362,7 @@ PRESETS_INPUT = { "-rtsp_transport", "tcp", TIMEOUT_PARAM, - "5000000", + "10000000", "-use_wallclock_as_timestamps", "1", ],