From 04550978796c5d6554486fede9deeb5a4cf9d88b Mon Sep 17 00:00:00 2001 From: Nick Mowen Date: Wed, 12 Jul 2023 20:32:51 -0600 Subject: [PATCH] Ensure that audio recording segments are kept --- frigate/record/maintainer.py | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/frigate/record/maintainer.py b/frigate/record/maintainer.py index d21affefa..4459eb285 100644 --- a/frigate/record/maintainer.py +++ b/frigate/record/maintainer.py @@ -201,6 +201,7 @@ class RecordingMaintainer(threading.Thread): duration, cache_path, record_mode, + events.data.get("type", "object") == "audio", ) # if it doesn't overlap with an event, go ahead and drop the segment # if it ends more than the configured pre_capture for the camera @@ -215,7 +216,13 @@ class RecordingMaintainer(threading.Thread): else: record_mode = self.config.cameras[camera].record.retain.mode self.store_segment( - camera, start_time, end_time, duration, cache_path, record_mode + camera, + start_time, + end_time, + duration, + cache_path, + record_mode, + events.data.get("type", "object") == "audio", ) def segment_stats( @@ -251,12 +258,14 @@ class RecordingMaintainer(threading.Thread): duration: float, cache_path: str, store_mode: RetainModeEnum, + audio_event: bool, ) -> None: motion_count, active_count = self.segment_stats(camera, start_time, end_time) # check if the segment shouldn't be stored - if (store_mode == RetainModeEnum.motion and motion_count == 0) or ( - store_mode == RetainModeEnum.active_objects and active_count == 0 + if not audio_event and ( + (store_mode == RetainModeEnum.motion and motion_count == 0) + or (store_mode == RetainModeEnum.active_objects and active_count == 0) ): Path(cache_path).unlink(missing_ok=True) self.end_time_cache.pop(cache_path, None) @@ -333,6 +342,7 @@ class RecordingMaintainer(threading.Thread): motion=motion_count, # TODO: update this to store list of active objects at some point objects=active_count, + audio=1 if audio_event else 0, segment_size=segment_size, ) except Exception as e: