configurable ffmpeg timeout (#6897)

* configurable ffmpeg timeout

* configurable ffmpeg healthcheck interval

rename timeout to healthcheck_interval
only grab config value once

* configurable ffmpeg retry interval

rename healthcheck_interval to retry_interval

* add retry_interval to docs

- update retry_interval text in config.py
This commit is contained in:
spacebares 2023-06-30 08:14:39 -04:00 committed by GitHub
parent 9137f1594b
commit ed0d2be321
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 12 additions and 2 deletions

View File

@ -189,6 +189,11 @@ ffmpeg:
record: preset-record-generic record: preset-record-generic
# Optional: output args for rtmp streams (default: shown below) # Optional: output args for rtmp streams (default: shown below)
rtmp: preset-rtmp-generic 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 # Optional: Detect configuration
# NOTE: Can be overridden at the camera level # NOTE: Can be overridden at the camera level

View File

@ -463,6 +463,10 @@ class FfmpegConfig(FrigateBaseModel):
default_factory=FfmpegOutputArgsConfig, default_factory=FfmpegOutputArgsConfig,
title="FFmpeg output arguments per role.", 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): class CameraRoleEnum(str, Enum):

View File

@ -234,6 +234,7 @@ class CameraWatchdog(threading.Thread):
self.frame_shape = self.config.frame_shape_yuv self.frame_shape = self.config.frame_shape_yuv
self.frame_size = self.frame_shape[0] * self.frame_shape[1] self.frame_size = self.frame_shape[0] * self.frame_shape[1]
self.stop_event = stop_event self.stop_event = stop_event
self.sleeptime = self.config.ffmpeg.retry_interval
def run(self): def run(self):
self.start_ffmpeg_detect() self.start_ffmpeg_detect()
@ -253,8 +254,8 @@ class CameraWatchdog(threading.Thread):
} }
) )
time.sleep(10) time.sleep(self.sleeptime)
while not self.stop_event.wait(10): while not self.stop_event.wait(self.sleeptime):
now = datetime.datetime.now().timestamp() now = datetime.datetime.now().timestamp()
if not self.capture_thread.is_alive(): if not self.capture_thread.is_alive():