mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-02-06 19:25:22 +03:00
Refactor export logic
This commit is contained in:
parent
5658e5a4cc
commit
98df20294b
@ -13,6 +13,7 @@ from frigate.ffmpeg_presets import (
|
|||||||
EncodeTypeEnum,
|
EncodeTypeEnum,
|
||||||
parse_preset_hardware_acceleration_encode,
|
parse_preset_hardware_acceleration_encode,
|
||||||
)
|
)
|
||||||
|
from frigate.models import Recordings
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
@ -58,13 +59,28 @@ class RecordingExporter(threading.Thread):
|
|||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
playlist_lines = []
|
playlist_lines = []
|
||||||
playlist_start = self.start_time
|
|
||||||
|
|
||||||
while playlist_start < self.end_time:
|
# get full set of recordings
|
||||||
playlist_lines.append(
|
export_recordings = (
|
||||||
f"file 'http://127.0.0.1:5000/vod/{self.camera}/start/{playlist_start}/end/{min(playlist_start + MAX_PLAYLIST_SECONDS, self.end_time)}/index.m3u8'"
|
Recordings.select()
|
||||||
|
.where(
|
||||||
|
Recordings.start_time.between(self.start_time, self.end_time)
|
||||||
|
| Recordings.end_time.between(self.start_time, self.end_time)
|
||||||
|
| ((self.start > Recordings.start_time) & (self.end_time < Recordings.end_time))
|
||||||
|
)
|
||||||
|
.where(Recordings.camera == self.camera)
|
||||||
|
.order_by(Recordings.start_time.asc())
|
||||||
|
)
|
||||||
|
|
||||||
|
# Use pagination to process records in chunks
|
||||||
|
page_size = 1000
|
||||||
|
num_pages = (export_recordings.count() + page_size - 1) // page_size
|
||||||
|
|
||||||
|
for page in range(num_pages):
|
||||||
|
page = export_recordings.paginate(page, page_size)
|
||||||
|
playlist_lines.append(
|
||||||
|
f"file 'http://127.0.0.1:5000/vod/{self.camera}/start/{page[0].start_time}/end/{page[-1].end_time}/index.m3u8'"
|
||||||
)
|
)
|
||||||
playlist_start += MAX_PLAYLIST_SECONDS
|
|
||||||
|
|
||||||
ffmpeg_input = "-y -protocol_whitelist pipe,file,http,tcp -f concat -safe 0 -i /dev/stdin"
|
ffmpeg_input = "-y -protocol_whitelist pipe,file,http,tcp -f concat -safe 0 -i /dev/stdin"
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user