mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-05-01 19:17:41 +03:00
Improve efficiency of frame listing for previews
This commit is contained in:
parent
b47a47c44a
commit
ea0f4b6a0f
@ -1368,12 +1368,17 @@ def preview_gif(
|
|||||||
file_start = f"preview_{camera_name}-"
|
file_start = f"preview_{camera_name}-"
|
||||||
start_file = f"{file_start}{start_ts}.{PREVIEW_FRAME_TYPE}"
|
start_file = f"{file_start}{start_ts}.{PREVIEW_FRAME_TYPE}"
|
||||||
end_file = f"{file_start}{end_ts}.{PREVIEW_FRAME_TYPE}"
|
end_file = f"{file_start}{end_ts}.{PREVIEW_FRAME_TYPE}"
|
||||||
|
|
||||||
|
camera_files = [
|
||||||
|
entry.name
|
||||||
|
for entry in os.scandir(preview_dir)
|
||||||
|
if entry.name.startswith(file_start)
|
||||||
|
]
|
||||||
|
camera_files.sort()
|
||||||
|
|
||||||
selected_previews = []
|
selected_previews = []
|
||||||
|
|
||||||
for file in sorted(os.listdir(preview_dir)):
|
for file in camera_files:
|
||||||
if not file.startswith(file_start):
|
|
||||||
continue
|
|
||||||
|
|
||||||
if file < start_file:
|
if file < start_file:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
@ -1550,12 +1555,17 @@ def preview_mp4(
|
|||||||
file_start = f"preview_{camera_name}-"
|
file_start = f"preview_{camera_name}-"
|
||||||
start_file = f"{file_start}{start_ts}.{PREVIEW_FRAME_TYPE}"
|
start_file = f"{file_start}{start_ts}.{PREVIEW_FRAME_TYPE}"
|
||||||
end_file = f"{file_start}{end_ts}.{PREVIEW_FRAME_TYPE}"
|
end_file = f"{file_start}{end_ts}.{PREVIEW_FRAME_TYPE}"
|
||||||
|
|
||||||
|
camera_files = [
|
||||||
|
entry.name
|
||||||
|
for entry in os.scandir(preview_dir)
|
||||||
|
if entry.name.startswith(file_start)
|
||||||
|
]
|
||||||
|
camera_files.sort()
|
||||||
|
|
||||||
selected_previews = []
|
selected_previews = []
|
||||||
|
|
||||||
for file in sorted(os.listdir(preview_dir)):
|
for file in camera_files:
|
||||||
if not file.startswith(file_start):
|
|
||||||
continue
|
|
||||||
|
|
||||||
if file < start_file:
|
if file < start_file:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
|||||||
@ -148,12 +148,17 @@ def get_preview_frames_from_cache(camera_name: str, start_ts: float, end_ts: flo
|
|||||||
file_start = f"preview_{camera_name}-"
|
file_start = f"preview_{camera_name}-"
|
||||||
start_file = f"{file_start}{start_ts}.{PREVIEW_FRAME_TYPE}"
|
start_file = f"{file_start}{start_ts}.{PREVIEW_FRAME_TYPE}"
|
||||||
end_file = f"{file_start}{end_ts}.{PREVIEW_FRAME_TYPE}"
|
end_file = f"{file_start}{end_ts}.{PREVIEW_FRAME_TYPE}"
|
||||||
|
|
||||||
|
camera_files = [
|
||||||
|
entry.name
|
||||||
|
for entry in os.scandir(preview_dir)
|
||||||
|
if entry.name.startswith(file_start)
|
||||||
|
]
|
||||||
|
camera_files.sort()
|
||||||
|
|
||||||
selected_previews = []
|
selected_previews = []
|
||||||
|
|
||||||
for file in sorted(os.listdir(preview_dir)):
|
for file in camera_files:
|
||||||
if not file.startswith(file_start):
|
|
||||||
continue
|
|
||||||
|
|
||||||
if file < start_file:
|
if file < start_file:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
|||||||
@ -366,12 +366,17 @@ class ReviewDescriptionProcessor(PostProcessorApi):
|
|||||||
file_start = f"preview_{camera}-"
|
file_start = f"preview_{camera}-"
|
||||||
start_file = f"{file_start}{start_time}.webp"
|
start_file = f"{file_start}{start_time}.webp"
|
||||||
end_file = f"{file_start}{end_time}.webp"
|
end_file = f"{file_start}{end_time}.webp"
|
||||||
|
|
||||||
|
camera_files = [
|
||||||
|
entry.name
|
||||||
|
for entry in os.scandir(preview_dir)
|
||||||
|
if entry.name.startswith(file_start)
|
||||||
|
]
|
||||||
|
camera_files.sort()
|
||||||
|
|
||||||
all_frames: list[str] = []
|
all_frames: list[str] = []
|
||||||
|
|
||||||
for file in sorted(os.listdir(preview_dir)):
|
for file in camera_files:
|
||||||
if not file.startswith(file_start):
|
|
||||||
continue
|
|
||||||
|
|
||||||
if file < start_file:
|
if file < start_file:
|
||||||
if len(all_frames):
|
if len(all_frames):
|
||||||
all_frames[0] = os.path.join(preview_dir, file)
|
all_frames[0] = os.path.join(preview_dir, file)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user