mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-05-01 19:17:41 +03:00
Recording config updates
This commit is contained in:
parent
3da1fdadd1
commit
9a340ee5fa
@ -441,7 +441,10 @@ class Dispatcher:
|
|||||||
logger.info(f"Turning off audio detection for {camera_name}")
|
logger.info(f"Turning off audio detection for {camera_name}")
|
||||||
audio_settings.enabled = False
|
audio_settings.enabled = False
|
||||||
|
|
||||||
self.config_updater.publish(f"config/audio/{camera_name}", audio_settings)
|
self.config_updater.publish_update(
|
||||||
|
CameraConfigUpdateTopic(CameraConfigUpdateEnum.audio, camera_name),
|
||||||
|
audio_settings,
|
||||||
|
)
|
||||||
self.publish(f"{camera_name}/audio/state", payload, retain=True)
|
self.publish(f"{camera_name}/audio/state", payload, retain=True)
|
||||||
|
|
||||||
def _on_recordings_command(self, camera_name: str, payload: str) -> None:
|
def _on_recordings_command(self, camera_name: str, payload: str) -> None:
|
||||||
@ -463,7 +466,10 @@ class Dispatcher:
|
|||||||
logger.info(f"Turning off recordings for {camera_name}")
|
logger.info(f"Turning off recordings for {camera_name}")
|
||||||
record_settings.enabled = False
|
record_settings.enabled = False
|
||||||
|
|
||||||
self.config_updater.publish(f"config/record/{camera_name}", record_settings)
|
self.config_updater.publish_update(
|
||||||
|
CameraConfigUpdateTopic(CameraConfigUpdateEnum.record, camera_name),
|
||||||
|
record_settings,
|
||||||
|
)
|
||||||
self.publish(f"{camera_name}/recordings/state", payload, retain=True)
|
self.publish(f"{camera_name}/recordings/state", payload, retain=True)
|
||||||
|
|
||||||
def _on_snapshots_command(self, camera_name: str, payload: str) -> None:
|
def _on_snapshots_command(self, camera_name: str, payload: str) -> None:
|
||||||
|
|||||||
@ -83,11 +83,11 @@ class CameraConfigUpdateSubscriber:
|
|||||||
config.motion = updated_config
|
config.motion = updated_config
|
||||||
elif update_type == CameraConfigUpdateEnum.notifications:
|
elif update_type == CameraConfigUpdateEnum.notifications:
|
||||||
config.notifications = updated_config
|
config.notifications = updated_config
|
||||||
elif updated_config == CameraConfigUpdateEnum.record:
|
elif update_type == CameraConfigUpdateEnum.record:
|
||||||
config.record = updated_config
|
config.record = updated_config
|
||||||
elif updated_config == CameraConfigUpdateEnum.review:
|
elif update_type == CameraConfigUpdateEnum.review:
|
||||||
config.review = updated_config
|
config.review = updated_config
|
||||||
elif updated_config == CameraConfigUpdateEnum.snapshots:
|
elif update_type == CameraConfigUpdateEnum.snapshots:
|
||||||
config.snapshots = updated_config
|
config.snapshots = updated_config
|
||||||
elif update_type == CameraConfigUpdateEnum.zones:
|
elif update_type == CameraConfigUpdateEnum.zones:
|
||||||
config.zones = updated_config
|
config.zones = updated_config
|
||||||
|
|||||||
@ -102,8 +102,8 @@ def output_frames(
|
|||||||
websocket_thread = threading.Thread(target=websocket_server.serve_forever)
|
websocket_thread = threading.Thread(target=websocket_server.serve_forever)
|
||||||
|
|
||||||
detection_subscriber = DetectionSubscriber(DetectionTypeEnum.video)
|
detection_subscriber = DetectionSubscriber(DetectionTypeEnum.video)
|
||||||
config_subsriber = CameraConfigUpdateSubscriber(
|
config_subscriber = CameraConfigUpdateSubscriber(
|
||||||
config.cameras, [CameraConfigUpdateEnum.enabled]
|
config.cameras, [CameraConfigUpdateEnum.enabled, CameraConfigUpdateEnum.record]
|
||||||
)
|
)
|
||||||
|
|
||||||
jsmpeg_cameras: dict[str, JsmpegCamera] = {}
|
jsmpeg_cameras: dict[str, JsmpegCamera] = {}
|
||||||
@ -116,7 +116,7 @@ def output_frames(
|
|||||||
move_preview_frames("cache")
|
move_preview_frames("cache")
|
||||||
|
|
||||||
for camera, cam_config in config.cameras.items():
|
for camera, cam_config in config.cameras.items():
|
||||||
if not cam_config.enabled:
|
if not cam_config.enabled_in_config:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
jsmpeg_cameras[camera] = JsmpegCamera(cam_config, stop_event, websocket_server)
|
jsmpeg_cameras[camera] = JsmpegCamera(cam_config, stop_event, websocket_server)
|
||||||
@ -130,7 +130,7 @@ def output_frames(
|
|||||||
|
|
||||||
while not stop_event.is_set():
|
while not stop_event.is_set():
|
||||||
# check if there is an updated config
|
# check if there is an updated config
|
||||||
config_subsriber.check_for_updates()
|
config_subscriber.check_for_updates()
|
||||||
|
|
||||||
(topic, data) = detection_subscriber.check_for_update(timeout=1)
|
(topic, data) = detection_subscriber.check_for_update(timeout=1)
|
||||||
now = datetime.datetime.now().timestamp()
|
now = datetime.datetime.now().timestamp()
|
||||||
@ -234,7 +234,7 @@ def output_frames(
|
|||||||
if birdseye is not None:
|
if birdseye is not None:
|
||||||
birdseye.stop()
|
birdseye.stop()
|
||||||
|
|
||||||
config_subsriber.stop()
|
config_subscriber.stop()
|
||||||
websocket_server.manager.close_all()
|
websocket_server.manager.close_all()
|
||||||
websocket_server.manager.stop()
|
websocket_server.manager.stop()
|
||||||
websocket_server.manager.join()
|
websocket_server.manager.join()
|
||||||
|
|||||||
@ -13,7 +13,6 @@ from typing import Any
|
|||||||
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
|
||||||
@ -174,9 +173,6 @@ 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}", True
|
|
||||||
)
|
|
||||||
|
|
||||||
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,
|
||||||
@ -323,12 +319,6 @@ class PreviewRecorder:
|
|||||||
) -> None:
|
) -> None:
|
||||||
self.offline = False
|
self.offline = False
|
||||||
|
|
||||||
# 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
|
||||||
|
|||||||
@ -16,7 +16,6 @@ from typing import Any, Optional, Tuple
|
|||||||
import numpy as np
|
import numpy as np
|
||||||
import psutil
|
import psutil
|
||||||
|
|
||||||
from frigate.comms.config_updater import ConfigSubscriber
|
|
||||||
from frigate.comms.detections_updater import DetectionSubscriber, DetectionTypeEnum
|
from frigate.comms.detections_updater import DetectionSubscriber, DetectionTypeEnum
|
||||||
from frigate.comms.inter_process import InterProcessRequestor
|
from frigate.comms.inter_process import InterProcessRequestor
|
||||||
from frigate.comms.recordings_updater import (
|
from frigate.comms.recordings_updater import (
|
||||||
@ -24,6 +23,10 @@ from frigate.comms.recordings_updater import (
|
|||||||
RecordingsDataTypeEnum,
|
RecordingsDataTypeEnum,
|
||||||
)
|
)
|
||||||
from frigate.config import FrigateConfig, RetainModeEnum
|
from frigate.config import FrigateConfig, RetainModeEnum
|
||||||
|
from frigate.config.camera.updater import (
|
||||||
|
CameraConfigUpdateEnum,
|
||||||
|
CameraConfigUpdateSubscriber,
|
||||||
|
)
|
||||||
from frigate.const import (
|
from frigate.const import (
|
||||||
CACHE_DIR,
|
CACHE_DIR,
|
||||||
CACHE_SEGMENT_FORMAT,
|
CACHE_SEGMENT_FORMAT,
|
||||||
@ -71,7 +74,9 @@ class RecordingMaintainer(threading.Thread):
|
|||||||
|
|
||||||
# create communication for retained recordings
|
# create communication for retained recordings
|
||||||
self.requestor = InterProcessRequestor()
|
self.requestor = InterProcessRequestor()
|
||||||
self.config_subscriber = ConfigSubscriber("config/record/")
|
self.config_subscriber = CameraConfigUpdateSubscriber(
|
||||||
|
self.config.cameras, [CameraConfigUpdateEnum.record]
|
||||||
|
)
|
||||||
self.detection_subscriber = DetectionSubscriber(DetectionTypeEnum.all)
|
self.detection_subscriber = DetectionSubscriber(DetectionTypeEnum.all)
|
||||||
self.recordings_publisher = RecordingsDataPublisher(
|
self.recordings_publisher = RecordingsDataPublisher(
|
||||||
RecordingsDataTypeEnum.recordings_available_through
|
RecordingsDataTypeEnum.recordings_available_through
|
||||||
@ -518,17 +523,7 @@ class RecordingMaintainer(threading.Thread):
|
|||||||
run_start = datetime.datetime.now().timestamp()
|
run_start = datetime.datetime.now().timestamp()
|
||||||
|
|
||||||
# check if there is an updated config
|
# check if there is an updated config
|
||||||
while True:
|
self.config_subscriber.check_for_updates()
|
||||||
(
|
|
||||||
updated_topic,
|
|
||||||
updated_record_config,
|
|
||||||
) = self.config_subscriber.check_for_update()
|
|
||||||
|
|
||||||
if not updated_topic:
|
|
||||||
break
|
|
||||||
|
|
||||||
camera_name = updated_topic.rpartition("/")[-1]
|
|
||||||
self.config.cameras[camera_name].record = updated_record_config
|
|
||||||
|
|
||||||
stale_frame_count = 0
|
stale_frame_count = 0
|
||||||
stale_frame_count_threshold = 10
|
stale_frame_count_threshold = 10
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user