mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-02-13 14:45:25 +03:00
Simplify check
This commit is contained in:
parent
a87a9fbbf9
commit
5c8145171a
@ -11,6 +11,7 @@ from pathlib import Path
|
|||||||
import cv2
|
import cv2
|
||||||
import numpy as np
|
import numpy as np
|
||||||
|
|
||||||
|
from frigate.comms.config_updater import ConfigSubscriber
|
||||||
from frigate.comms.inter_process import InterProcessRequestor
|
from frigate.comms.inter_process import InterProcessRequestor
|
||||||
from frigate.config import CameraConfig, RecordQualityEnum
|
from frigate.config import CameraConfig, RecordQualityEnum
|
||||||
from frigate.const import CACHE_DIR, CLIPS_DIR, INSERT_PREVIEW, PREVIEW_FRAME_TYPE
|
from frigate.const import CACHE_DIR, CLIPS_DIR, INSERT_PREVIEW, PREVIEW_FRAME_TYPE
|
||||||
@ -169,6 +170,7 @@ class PreviewRecorder:
|
|||||||
|
|
||||||
# create communication for finished previews
|
# create communication for finished previews
|
||||||
self.requestor = InterProcessRequestor()
|
self.requestor = InterProcessRequestor()
|
||||||
|
self.config_subscriber = ConfigSubscriber(f"config/record/{self.config.name}")
|
||||||
|
|
||||||
y, u1, u2, v1, v2 = get_yuv_crop(
|
y, u1, u2, v1, v2 = get_yuv_crop(
|
||||||
self.config.frame_shape_yuv,
|
self.config.frame_shape_yuv,
|
||||||
@ -299,6 +301,12 @@ class PreviewRecorder:
|
|||||||
frame_time: float,
|
frame_time: float,
|
||||||
frame,
|
frame,
|
||||||
) -> None:
|
) -> None:
|
||||||
|
# check for updated record config
|
||||||
|
_, updated_record_config = self.config_subscriber.check_for_update()
|
||||||
|
|
||||||
|
if updated_record_config:
|
||||||
|
self.config.record = updated_record_config
|
||||||
|
|
||||||
# always write the first frame
|
# always write the first frame
|
||||||
if self.start_time == 0:
|
if self.start_time == 0:
|
||||||
self.start_time = frame_time
|
self.start_time = frame_time
|
||||||
@ -308,14 +316,18 @@ class PreviewRecorder:
|
|||||||
|
|
||||||
# check if PREVIEW clip should be generated and cached frames reset
|
# check if PREVIEW clip should be generated and cached frames reset
|
||||||
if frame_time >= self.segment_end:
|
if frame_time >= self.segment_end:
|
||||||
# save last frame to ensure consistent duration
|
if len(self.output_frames) > 0:
|
||||||
self.output_frames.append(frame_time)
|
# save last frame to ensure consistent duration
|
||||||
self.write_frame_to_cache(frame_time, frame)
|
if self.config.record:
|
||||||
FFMpegConverter(
|
self.output_frames.append(frame_time)
|
||||||
self.config,
|
self.write_frame_to_cache(frame_time, frame)
|
||||||
self.output_frames,
|
|
||||||
self.requestor,
|
# write the preview if any frames exist for this hour
|
||||||
).start()
|
FFMpegConverter(
|
||||||
|
self.config,
|
||||||
|
self.output_frames,
|
||||||
|
self.requestor,
|
||||||
|
).start()
|
||||||
|
|
||||||
# reset frame cache
|
# reset frame cache
|
||||||
self.segment_end = (
|
self.segment_end = (
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user