From cca6676004edd47589c1281520573ba9b00183a2 Mon Sep 17 00:00:00 2001 From: Nick Mowen Date: Thu, 20 Apr 2023 15:46:22 -0600 Subject: [PATCH] Setup timeline queue in events --- frigate/app.py | 10 ++++++---- frigate/events.py | 13 +++++++++++++ 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/frigate/app.py b/frigate/app.py index 5859aa553..94391ddfc 100644 --- a/frigate/app.py +++ b/frigate/app.py @@ -290,12 +290,17 @@ class FrigateApp: capture_process.start() logger.info(f"Capture process started for {name}: {capture_process.pid}") + def start_timeline_processor(self) -> None: + self.timeline_processor = TimelineProcessor(self.timeline_queue, self.stop_event) + self.timeline_processor.start() + def start_event_processor(self) -> None: self.event_processor = EventProcessor( self.config, self.camera_metrics, self.event_queue, self.event_processed_queue, + self.timeline_queue, self.stop_event, ) self.event_processor.start() @@ -318,10 +323,6 @@ class FrigateApp: self.storage_maintainer = StorageMaintainer(self.config, self.stop_event) self.storage_maintainer.start() - def start_timeline_processor(self) -> None: - self.timeline_processor = TimelineProcessor(self.timeline_queue, self.stop_event) - self.timeline_processor.start() - def start_stats_emitter(self) -> None: self.stats_emitter = StatsEmitter( self.config, @@ -392,6 +393,7 @@ class FrigateApp: self.start_storage_maintainer() self.init_stats() self.init_web_server() + self.start_timeline_processor() self.start_event_processor() self.start_event_cleanup() self.start_recording_maintainer() diff --git a/frigate/events.py b/frigate/events.py index f502c4ded..26a70ce42 100644 --- a/frigate/events.py +++ b/frigate/events.py @@ -11,6 +11,7 @@ from peewee import fn from frigate.config import EventsConfig, FrigateConfig, RecordConfig from frigate.const import CLIPS_DIR from frigate.models import Event +from frigate.timeline import InputTypeEnum from frigate.types import CameraMetricsTypes from multiprocessing.queues import Queue @@ -48,6 +49,7 @@ class EventProcessor(threading.Thread): camera_processes: dict[str, CameraMetricsTypes], event_queue: Queue, event_processed_queue: Queue, + timeline_queue: Queue, stop_event: MpEvent, ): threading.Thread.__init__(self) @@ -56,6 +58,7 @@ class EventProcessor(threading.Thread): self.camera_processes = camera_processes self.event_queue = event_queue self.event_processed_queue = event_processed_queue + self.timeline_queue = timeline_queue self.events_in_process: Dict[str, Event] = {} self.stop_event = stop_event @@ -73,6 +76,16 @@ class EventProcessor(threading.Thread): logger.debug(f"Event received: {event_type} {camera} {event_data['id']}") + self.timeline_queue.put( + ( + camera, + InputTypeEnum.tracked_object, + event_type, + self.events_in_process.get(event_data["id"]), + event_data, + ) + ) + event_config: EventsConfig = self.config.cameras[camera].record.events if event_type == "start":