Match preview frames to exact camera (#25067)

* match preview frames to the exact camera

Current-hour preview frames were selected with a "preview_{camera}-" prefix match, so a camera whose name extends another with "-" (front and front-door, cam and cam-2) had its frames included in the other camera's frame listing, preview GIF and MP4, and preview export. The frames listing, the GIF and MP4 routes, and the preview export now filter with is_camera_preview_frame.

* start preview frame tests ahead of now
This commit is contained in:
Josh Hawkins
2026-11-24 06:22:34 -07:00
committed by GitHub
parent 764ab2c4f0
commit 952ff4a076
5 changed files with 144 additions and 5 deletions
+6 -3
View File
@@ -47,7 +47,10 @@ from frigate.const import (
STREAM_TYPE_SUB,
)
from frigate.models import Event, Previews, Recordings, Regions, ReviewSegment
from frigate.output.preview import get_most_recent_preview_frame
from frigate.output.preview import (
get_most_recent_preview_frame,
is_camera_preview_frame,
)
from frigate.track.object_processing import TrackedObjectProcessor
from frigate.util.ffmpeg import terminate_ffmpeg_stream
from frigate.util.file import (
@@ -1606,7 +1609,7 @@ async def preview_gif(
camera_files = [
entry.name
for entry in os.scandir(preview_dir)
if entry.name.startswith(file_start)
if is_camera_preview_frame(entry.name, camera_name)
]
camera_files.sort()
@@ -1797,7 +1800,7 @@ async def preview_mp4(
camera_files = [
entry.name
for entry in os.scandir(preview_dir)
if entry.name.startswith(file_start)
if is_camera_preview_frame(entry.name, camera_name)
]
camera_files.sort()
+2 -1
View File
@@ -22,6 +22,7 @@ from frigate.api.defs.response.preview_response import (
from frigate.api.defs.tags import Tags
from frigate.const import BASE_DIR, CACHE_DIR, PREVIEW_FRAME_TYPE
from frigate.models import Previews
from frigate.output.preview import is_camera_preview_frame
from frigate.util.time import get_normalized_tz_name
logger = logging.getLogger(__name__)
@@ -187,7 +188,7 @@ def get_preview_frames_from_cache(camera_name: str, start_ts: float, end_ts: flo
left = bisect.bisect_left(files, start_file)
right = bisect.bisect_right(files, end_file)
selected_previews = [
file for file in files[left:right] if file.startswith(file_start)
file for file in files[left:right] if is_camera_preview_frame(file, camera_name)
]
return JSONResponse(