diff --git a/docs/docs/configuration/index.md b/docs/docs/configuration/index.md index ac65a1018..496247f37 100644 --- a/docs/docs/configuration/index.md +++ b/docs/docs/configuration/index.md @@ -189,6 +189,11 @@ ffmpeg: record: preset-record-generic # Optional: output args for rtmp streams (default: shown below) rtmp: preset-rtmp-generic + # Optional: Time in seconds to wait before ffmpeg retries connecting to the camera. (default: shown below) + # If set too low, frigate will retry a connection to the camera's stream too frequently, using up the limited streams some cameras can allow at once + # If set too high, then if a ffmpeg crash or camera stream timeout occurs, you could potentially lose up to a maximum of retry_interval second(s) of footage + # NOTE: this can be a useful setting for Wireless / Battery cameras to reduce how much footage is potentially lost during a connection timeout. + retry_interval: 10 # Optional: Detect configuration # NOTE: Can be overridden at the camera level diff --git a/frigate/config.py b/frigate/config.py index b71ba1907..4bc7e1a01 100644 --- a/frigate/config.py +++ b/frigate/config.py @@ -463,6 +463,10 @@ class FfmpegConfig(FrigateBaseModel): default_factory=FfmpegOutputArgsConfig, title="FFmpeg output arguments per role.", ) + retry_interval: float = Field( + default=10.0, + title="Time in seconds to wait before FFmpeg retries connecting to the camera.", + ) class CameraRoleEnum(str, Enum): diff --git a/frigate/video.py b/frigate/video.py index 4f315885c..8980fcde0 100755 --- a/frigate/video.py +++ b/frigate/video.py @@ -234,6 +234,7 @@ class CameraWatchdog(threading.Thread): self.frame_shape = self.config.frame_shape_yuv self.frame_size = self.frame_shape[0] * self.frame_shape[1] self.stop_event = stop_event + self.sleeptime = self.config.ffmpeg.retry_interval def run(self): self.start_ffmpeg_detect() @@ -253,8 +254,8 @@ class CameraWatchdog(threading.Thread): } ) - time.sleep(10) - while not self.stop_event.wait(10): + time.sleep(self.sleeptime) + while not self.stop_event.wait(self.sleeptime): now = datetime.datetime.now().timestamp() if not self.capture_thread.is_alive():