From 1bf4bc8af8a0013cd76a1fce880eaa949f3526f3 Mon Sep 17 00:00:00 2001 From: Josh Hawkins <32435876+hawkeye217@users.noreply.github.com> Date: Wed, 6 May 2026 20:15:49 -0500 Subject: [PATCH] rebuild ffmpeg commands when enabling recording for the first time Toggling record.enabled from the config UI updated the in-memory config but left ffmpeg running with its original command, so the record output args were never wired in and nothing landed in the cache for the maintainer to move. The record config update now rebuilds ffmpeg_cmds when enabled_in_config transitions, and the camera watchdog restarts ffmpeg on a false to true transition so the record output gets wired in. MQTT toggles, which only flip record.enabled at runtime, are unaffected and continue to work via the maintainer's drop/keep gate. --- frigate/config/camera/updater.py | 3 +++ frigate/video/ffmpeg.py | 17 +++++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/frigate/config/camera/updater.py b/frigate/config/camera/updater.py index a07d51b8e..95092da08 100644 --- a/frigate/config/camera/updater.py +++ b/frigate/config/camera/updater.py @@ -121,7 +121,10 @@ class CameraConfigUpdateSubscriber: elif update_type == CameraConfigUpdateEnum.objects: config.objects = updated_config elif update_type == CameraConfigUpdateEnum.record: + old_enabled_in_config = config.record.enabled_in_config config.record = updated_config + if old_enabled_in_config != updated_config.enabled_in_config: + config.recreate_ffmpeg_cmds() elif update_type == CameraConfigUpdateEnum.review: config.review = updated_config elif update_type == CameraConfigUpdateEnum.review_genai: diff --git a/frigate/video/ffmpeg.py b/frigate/video/ffmpeg.py index 3d8b18105..e77c03b5e 100644 --- a/frigate/video/ffmpeg.py +++ b/frigate/video/ffmpeg.py @@ -174,6 +174,7 @@ class CameraWatchdog(threading.Thread): ) self.requestor = InterProcessRequestor() self.was_enabled = self.config.enabled + self.was_record_enabled_in_config = self.config.record.enabled_in_config self.segment_subscriber = RecordingsDataSubscriber(RecordingsDataTypeEnum.all) self.latest_valid_segment_time: float = 0 @@ -323,6 +324,22 @@ class CameraWatchdog(threading.Thread): self.was_enabled = enabled continue + record_enabled_in_config = self.config.record.enabled_in_config + if record_enabled_in_config != self.was_record_enabled_in_config: + if record_enabled_in_config and enabled: + self.logger.debug( + f"Record enabled in config for {self.config.name}, restarting ffmpeg" + ) + self.stop_all_ffmpeg() + self.start_all_ffmpeg() + self.latest_valid_segment_time = 0 + self.latest_invalid_segment_time = 0 + self.latest_cache_segment_time = 0 + self.record_enable_time = datetime.now().astimezone(timezone.utc) + last_restart_time = datetime.now().timestamp() + self.was_record_enabled_in_config = record_enabled_in_config + continue + if not enabled: continue