NVR with realtime local object detection for IP cameras
TypeScript aicameragoogle-coralhome-assistanthome-automationhomeautomationmqttnvrobject-detectionrealtimertsptensorflow
Handle recording checks in utc (#8379)
Nicolas Mowene89dafa82ea4
diff --git a/frigate/record/maintainer.py b/frigate/record/maintainer.pyindex b0969b7ef1..0520e086a7 100644--- a/frigate/record/maintainer.py+++ b/frigate/record/maintainer.py@@ -260,8 +260,10 @@ class RecordingMaintainer(threading.Thread):most_recently_processed_frame_time = (camera_info[-1][0] if len(camera_info) > 0 else 0)- retain_cutoff = most_recently_processed_frame_time - pre_capture- if end_time.timestamp() < retain_cutoff:+ retain_cutoff = datetime.datetime.fromtimestamp(+ most_recently_processed_frame_time - pre_capture+ ).astimezone(datetime.timezone.utc)+ if end_time.astimezone(datetime.timezone.utc) < retain_cutoff:Path(cache_path).unlink(missing_ok=True)self.end_time_cache.pop(cache_path, None)# else retain days includes this segment@@ -273,7 +275,11 @@ class RecordingMaintainer(threading.Thread):)# ensure delayed segment info does not lead to lost segments- if most_recently_processed_frame_time >= end_time.timestamp():+ if datetime.datetime.fromtimestamp(+ most_recently_processed_frame_time+ ).astimezone(datetime.timezone.utc) >= end_time.astimezone(+ datetime.timezone.utc+ ):record_mode = self.config.cameras[camera].record.retain.modereturn await self.move_segment(camera, start_time, end_time, duration, cache_path, record_modediff --git a/frigate/video.py b/frigate/video.pyindex b479fd7254..23b3481cf8 100755--- a/frigate/video.py+++ b/frigate/video.py@@ -233,14 +233,15 @@ class CameraWatchdog(threading.Thread):poll = p["process"].poll()if self.config.record.enabled and "record" in p["roles"]:- latest_segment_time = self.get_latest_segment_timestamp(+ latest_segment_time = self.get_latest_segment_datetime(p.get(- "latest_segment_time", datetime.datetime.now().timestamp()+ "latest_segment_time",+ datetime.datetime.now().astimezone(datetime.timezone.utc),))- if datetime.datetime.now().timestamp() > (- latest_segment_time + 120+ if datetime.datetime.now().astimezone(datetime.timezone.utc) > (+ latest_segment_time + datetime.timedelta(seconds=120)):self.logger.error(f"No new recording segments were created for {self.camera_name} in the last 120s. restarting the ffmpeg record process..."@@ -288,7 +289,7 @@ class CameraWatchdog(threading.Thread):)self.capture_thread.start()- def get_latest_segment_timestamp(self, latest_timestamp) -> int:+ def get_latest_segment_datetime(self, latest_segment: datetime.datetime) -> int:"""Checks if ffmpeg is still writing recording segments to cache."""cache_files = sorted([@@ -299,13 +300,15 @@ class CameraWatchdog(threading.Thread):and not d.startswith("clip_")])- newest_segment_timestamp = latest_timestamp+ newest_segment_timestamp = latest_segmentfor file in cache_files:if self.camera_name in file:basename = os.path.splitext(file)[0]_, date = basename.rsplit("-", maxsplit=1)- ts = datetime.datetime.strptime(date, "%Y%m%d%H%M%S").timestamp()+ ts = datetime.datetime.strptime(date, "%Y%m%d%H%M%S").astimezone(+ datetime.timezone.utc+ )if ts > newest_segment_timestamp:newest_segment_timestamp = ts