From 63b3b8600588da2d5c2064357c64ec7613506bca Mon Sep 17 00:00:00 2001 From: Nicolas Mowen Date: Fri, 20 Jun 2025 16:05:15 -0600 Subject: [PATCH] Improve clip buffer and remove outdated comments --- frigate/api/media.py | 2 +- .../overlay/detail/SearchDetailDialog.tsx | 15 +++++++++------ 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/frigate/api/media.py b/frigate/api/media.py index a82d7f617..9cb00ae0b 100644 --- a/frigate/api/media.py +++ b/frigate/api/media.py @@ -598,7 +598,7 @@ def recording_clip( if clip.start_time < start_ts: file.write(f"inpoint {int(start_ts - clip.start_time)}\n") - # if this is the ending clip and end trim is enabled, add an outpoint + # if this is the ending clip, add an outpoint if clip.end_time > end_ts: file.write(f"outpoint {int(end_ts - clip.start_time)}\n") diff --git a/web/src/components/overlay/detail/SearchDetailDialog.tsx b/web/src/components/overlay/detail/SearchDetailDialog.tsx index 521ddde66..db2d82a6a 100644 --- a/web/src/components/overlay/detail/SearchDetailDialog.tsx +++ b/web/src/components/overlay/detail/SearchDetailDialog.tsx @@ -48,7 +48,7 @@ import { TooltipContent, TooltipTrigger, } from "@/components/ui/tooltip"; -import { ReviewSegment } from "@/types/review"; +import { REVIEW_PADDING, ReviewSegment } from "@/types/review"; import { useNavigate } from "react-router-dom"; import Chip from "@/components/indicators/Chip"; import { capitalizeAll } from "@/utils/stringUtil"; @@ -1229,11 +1229,14 @@ export function VideoTab({ search }: VideoTabProps) { const { data: reviewItem } = useSWR([ `review/event/${search.id}`, ]); - const endTime = useMemo(() => search.end_time ?? Date.now() / 1000, [search]); - // subtract 2 seconds from start_time to account for keyframes and any differences in the record/detect streams - // to help the start of the event from not being completely cut off - const source = `${baseUrl}vod/${search.camera}/start/${search.start_time - 2}/end/${endTime}/index.m3u8`; + const clipTimeRange = useMemo(() => { + const startTime = search.start_time - REVIEW_PADDING; + const endTime = (search.end_time ?? Date.now() / 1000) + REVIEW_PADDING; + return `start/${startTime}/end/${endTime}`; + }, [search]); + + const source = `${baseUrl}vod/${search.camera}/${clipTimeRange}/index.m3u8`; return ( <> @@ -1272,7 +1275,7 @@ export function VideoTab({ search }: VideoTabProps) {