From fc758ade897bdbf7b0d1f46eab5a661d54e17c26 Mon Sep 17 00:00:00 2001 From: Nicolas Mowen Date: Fri, 21 Nov 2025 07:21:55 -0700 Subject: [PATCH] Set minimum duration for recording segments Due to the inpoint logic, some recordings would get clipped on the end of the segment with a non-zero duration but not enough duration to include a frame. 100 ms is a safe value for any video that is 10fps or higher to have a frame --- frigate/api/media.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/frigate/api/media.py b/frigate/api/media.py index a8eb71ce1..372404b5a 100644 --- a/frigate/api/media.py +++ b/frigate/api/media.py @@ -849,6 +849,7 @@ async def vod_ts(camera_name: str, start_ts: float, end_ts: float): clips = [] durations = [] + min_duration_ms = 100 # Minimum 100ms to ensure at least one video frame max_duration_ms = MAX_SEGMENT_DURATION * 1000 recording: Recordings @@ -866,11 +867,11 @@ async def vod_ts(camera_name: str, start_ts: float, end_ts: float): if recording.end_time > end_ts: duration -= int((recording.end_time - end_ts) * 1000) - if duration <= 0: - # skip if the clip has no valid duration + if duration < min_duration_ms: + # skip if the clip has no valid duration (too short to contain frames) continue - if 0 < duration < max_duration_ms: + if min_duration_ms <= duration < max_duration_ms: clip["keyFrameDurations"] = [duration] clips.append(clip) durations.append(duration)