From 9091fc4c4abc44dcd5570dde29e9bbad3ff3b457 Mon Sep 17 00:00:00 2001 From: Nicolas Mowen Date: Fri, 8 Mar 2024 15:07:34 -0700 Subject: [PATCH] simplify --- frigate/output/preview.py | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/frigate/output/preview.py b/frigate/output/preview.py index de9dccce7..1f02f7107 100644 --- a/frigate/output/preview.py +++ b/frigate/output/preview.py @@ -201,13 +201,13 @@ class PreviewRecorder: frame_time: float, ) -> bool: """Decide if this frame should be added to PREVIEW.""" + active_objs = get_active_objects(frame_time, self.config, current_tracked_objects) + preview_output_fps = ( 2 if any( o["label"] == "car" - for o in get_active_objects( - frame_time, self.config, current_tracked_objects - ) + for o in active_objs ) else 1 ) @@ -217,10 +217,7 @@ class PreviewRecorder: return False # send frame if a non-stationary object is in a zone - if any( - (len(o["current_zones"]) > 0 and not o["stationary"]) - for o in current_tracked_objects - ): + if len(active_objs > 0): self.last_output_time = frame_time return True @@ -228,6 +225,11 @@ class PreviewRecorder: self.last_output_time = frame_time return True + # ensure that at least 2 frames are written every minute + if frame_time - self.last_output_time > 30: + self.last_output_time = frame_time + return True + return False def write_frame_to_cache(self, frame_time: float, frame) -> None: