From fd204b5a3ad8267554354401afe09ce911be51d1 Mon Sep 17 00:00:00 2001 From: Nicolas Mowen Date: Tue, 2 Apr 2024 06:10:06 -0600 Subject: [PATCH] Store recordings for manual events --- frigate/record/maintainer.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/frigate/record/maintainer.py b/frigate/record/maintainer.py index 3a9bb5bba..072c80327 100644 --- a/frigate/record/maintainer.py +++ b/frigate/record/maintainer.py @@ -165,6 +165,7 @@ class RecordingMaintainer(threading.Thread): Event.select( Event.start_time, Event.end_time, + Event.data, ) .where( Event.camera == camera, @@ -188,7 +189,7 @@ class RecordingMaintainer(threading.Thread): ) async def validate_and_move_segment( - self, camera: str, events: Event, recording: dict[str, any] + self, camera: str, events: list[Event], recording: dict[str, any] ) -> None: cache_path = recording["cache_path"] start_time = recording["start_time"] @@ -256,6 +257,7 @@ class RecordingMaintainer(threading.Thread): duration, cache_path, record_mode, + event.data["type"] == "api", ) # 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 @@ -347,11 +349,12 @@ class RecordingMaintainer(threading.Thread): duration: float, cache_path: str, store_mode: RetainModeEnum, + manual_event: bool = False, # if this segment is being moved due to a manual event ) -> Optional[Recordings]: segment_info = self.segment_stats(camera, start_time, end_time) # check if the segment shouldn't be stored - if segment_info.should_discard_segment(store_mode): + if not manual_event and segment_info.should_discard_segment(store_mode): Path(cache_path).unlink(missing_ok=True) self.end_time_cache.pop(cache_path, None) return @@ -424,7 +427,8 @@ class RecordingMaintainer(threading.Thread): Recordings.duration: duration, Recordings.motion: segment_info.motion_count, # TODO: update this to store list of active objects at some point - Recordings.objects: segment_info.active_object_count, + Recordings.objects: segment_info.active_object_count + + (1 if manual_event else 0), Recordings.regions: segment_info.region_count, Recordings.dBFS: segment_info.average_dBFS, Recordings.segment_size: segment_size,