NVR with realtime local object detection for IP cameras
TypeScript aicameragoogle-coralhome-assistanthome-automationhomeautomationmqttnvrobject-detectionrealtimertsptensorflow
Consider pre and post capture when cleaning up recordings based on review segments (#16096)
Nicolas Mowen776bb79f0be5
diff --git a/frigate/record/cleanup.py b/frigate/record/cleanup.pyindex b70a23b45d..e526b020d1 100644--- a/frigate/record/cleanup.py+++ b/frigate/record/cleanup.py@@ -121,22 +121,29 @@ class RecordingCleanup(threading.Thread):review_start = 0deleted_recordings = set()kept_recordings: list[tuple[float, float]] = []+ recording: Recordingsfor recording in recordings:keep = Falsemode = None# Now look for a reason to keep this recording segmentfor idx in range(review_start, len(reviews)):review: ReviewSegment = reviews[idx]+ severity = review.severity+ pre_capture = config.record.get_review_pre_capture(severity)+ post_capture = config.record.get_review_post_capture(severity)# if the review starts in the future, stop checking reviews# and let this recording segment expire- if review.start_time > recording.end_time:+ if review.start_time - pre_capture > recording.end_time:keep = Falsebreak# if the review is in progress or ends after the recording starts, keep it# and stop looking at reviews- if review.end_time is None or review.end_time >= recording.start_time:+ if (+ review.end_time is None+ or review.end_time + post_capture >= recording.start_time+ ):keep = Truemode = (config.record.alerts.retain.mode@@ -149,7 +156,7 @@ class RecordingCleanup(threading.Thread):# this review and check the next review for an overlap.# since the review and recordings are sorted, we can skip review# that end before the previous recording segment started on future segments- if review.end_time < recording.start_time:+ if review.end_time + post_capture < recording.start_time:review_start = idx# Delete recordings outside of the retention window or based on the retention mode