diff --git a/docker/Dockerfile.wheels b/docker/Dockerfile.wheels index 15f244671..b2b14bb97 100644 --- a/docker/Dockerfile.wheels +++ b/docker/Dockerfile.wheels @@ -32,7 +32,8 @@ RUN pip3 wheel --wheel-dir=/wheels \ paho-mqtt \ PyYAML \ matplotlib \ - click + click \ + tinydb FROM scratch diff --git a/docker/Dockerfile.wheels.aarch64 b/docker/Dockerfile.wheels.aarch64 index 006f569cf..17e048954 100644 --- a/docker/Dockerfile.wheels.aarch64 +++ b/docker/Dockerfile.wheels.aarch64 @@ -42,7 +42,8 @@ RUN pip3 wheel --wheel-dir=/wheels \ paho-mqtt \ PyYAML \ matplotlib \ - click + click \ + tinydb FROM scratch diff --git a/frigate/events.py b/frigate/events.py index ed2dfb473..51bfef392 100644 --- a/frigate/events.py +++ b/frigate/events.py @@ -7,6 +7,7 @@ import json import datetime import subprocess as sp import queue +from tinydb import TinyDB class EventProcessor(threading.Thread): def __init__(self, config, camera_processes, cache_dir, clip_dir, event_queue, stop_event): @@ -19,6 +20,7 @@ class EventProcessor(threading.Thread): self.event_queue = event_queue self.events_in_process = {} self.stop_event = stop_event + self.db = TinyDB(f"{os.path.join(self.clip_dir, 'events')}.json") def refresh_cache(self): cached_files = os.listdir(self.cache_dir) @@ -176,6 +178,16 @@ class EventProcessor(threading.Thread): self.events_in_process[event_data['id']] = event_data if event_type == 'end': + self.db.insert({ + 'id': event_data['id'], + 'label': event_data['label'], + 'camera': camera, + 'start_time': event_data['start_time'], + 'end_time': event_data['end_time'], + 'top_score': event_data['top_score'], + 'false_positive': event_data['false_positive'], + 'zones': list(event_data['entered_zones']) + }) if len(self.cached_clips) > 0 and not event_data['false_positive']: self.create_clip(camera, event_data, save_clips_config.get('pre_capture', 30)) del self.events_in_process[event_data['id']]