mirror of
https://github.com/blakeblackshear/frigate.git
synced 2025-01-02 00:07:11 +01:00
Refactor Exports To Better Handle Recording Configs (#7846)
* Refactor export logic * Fix param * Ensure float is used * Fix variable assignment * Fix range * Formatting
This commit is contained in:
parent
76d4f16db3
commit
111933d3b4
@ -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__)
|
||||||
|
|
||||||
@ -62,13 +63,31 @@ 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_time > 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(1, num_pages + 1):
|
||||||
|
playlist = export_recordings.paginate(page, page_size)
|
||||||
|
playlist_lines.append(
|
||||||
|
f"file 'http://127.0.0.1:5000/vod/{self.camera}/start/{float(playlist[0].start_time)}/end/{float(playlist[-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