mirror of
https://github.com/blakeblackshear/frigate.git
synced 2024-11-21 19:07:46 +01:00
prevent the cache from growing indefinitely
This commit is contained in:
parent
fdc8bbf72d
commit
7880d24b29
@ -17,6 +17,17 @@ mqtt:
|
|||||||
#################
|
#################
|
||||||
# password: password # Optional
|
# password: password # Optional
|
||||||
|
|
||||||
|
################
|
||||||
|
# Global configuration for saving clips
|
||||||
|
################
|
||||||
|
save_clips:
|
||||||
|
###########
|
||||||
|
# Maximum length of time to retain video during long events.
|
||||||
|
# If an object is being tracked for longer than this amount of time, the cache
|
||||||
|
# will begin to expire and the resulting clip will be the last x seconds of the event.
|
||||||
|
###########
|
||||||
|
max_seconds: 300
|
||||||
|
|
||||||
#################
|
#################
|
||||||
# Default ffmpeg args. Optional and can be overwritten per camera.
|
# Default ffmpeg args. Optional and can be overwritten per camera.
|
||||||
# Should work with most RTSP cameras that send h264 video
|
# Should work with most RTSP cameras that send h264 video
|
||||||
|
@ -290,7 +290,7 @@ def main():
|
|||||||
camera_process['process'].start()
|
camera_process['process'].start()
|
||||||
print(f"Camera_process started for {name}: {camera_process['process'].pid}")
|
print(f"Camera_process started for {name}: {camera_process['process'].pid}")
|
||||||
|
|
||||||
event_processor = EventProcessor(CONFIG['cameras'], camera_processes, '/cache', '/clips', event_queue, stop_event)
|
event_processor = EventProcessor(CONFIG, camera_processes, '/cache', '/clips', event_queue, stop_event)
|
||||||
event_processor.start()
|
event_processor.start()
|
||||||
|
|
||||||
object_processor = TrackedObjectProcessor(CONFIG['cameras'], client, MQTT_TOPIC_PREFIX, tracked_objects_queue, event_queue, stop_event)
|
object_processor = TrackedObjectProcessor(CONFIG['cameras'], client, MQTT_TOPIC_PREFIX, tracked_objects_queue, event_queue, stop_event)
|
||||||
|
@ -73,6 +73,11 @@ class EventProcessor(threading.Thread):
|
|||||||
earliest_event = min(self.events_in_process.values(), key=lambda x:x['start_time'])['start_time']
|
earliest_event = min(self.events_in_process.values(), key=lambda x:x['start_time'])['start_time']
|
||||||
else:
|
else:
|
||||||
earliest_event = datetime.datetime.now().timestamp()
|
earliest_event = datetime.datetime.now().timestamp()
|
||||||
|
|
||||||
|
# if the earliest event exceeds the max seconds, cap it
|
||||||
|
max_seconds = self.config.get('save_clips', {}).get('max_seconds', 300)
|
||||||
|
if datetime.datetime.now().timestamp()-earliest_event > max_seconds:
|
||||||
|
earliest_event = datetime.datetime.now().timestamp()-max_seconds
|
||||||
|
|
||||||
for f, data in list(self.cached_clips.items()):
|
for f, data in list(self.cached_clips.items()):
|
||||||
if earliest_event-90 > data['start_time']+data['duration']:
|
if earliest_event-90 > data['start_time']+data['duration']:
|
||||||
@ -147,7 +152,11 @@ class EventProcessor(threading.Thread):
|
|||||||
|
|
||||||
self.refresh_cache()
|
self.refresh_cache()
|
||||||
|
|
||||||
save_clips_config = self.config[camera].get('save_clips', {})
|
save_clips_config = self.config['cameras'][camera].get('save_clips', {})
|
||||||
|
|
||||||
|
# if save clips is not enabled for this camera, just continue
|
||||||
|
if not save_clips_config.get('enabled', False):
|
||||||
|
continue
|
||||||
|
|
||||||
# if specific objects are listed for this camera, only save clips for them
|
# if specific objects are listed for this camera, only save clips for them
|
||||||
if 'objects' in save_clips_config:
|
if 'objects' in save_clips_config:
|
||||||
@ -158,7 +167,7 @@ class EventProcessor(threading.Thread):
|
|||||||
self.events_in_process[event_data['id']] = event_data
|
self.events_in_process[event_data['id']] = event_data
|
||||||
|
|
||||||
if event_type == 'end':
|
if event_type == 'end':
|
||||||
if save_clips_config.get('enabled', False) and len(self.cached_clips) > 0 and not event_data['false_positive']:
|
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))
|
self.create_clip(camera, event_data, save_clips_config.get('pre_capture', 30))
|
||||||
del self.events_in_process[event_data['id']]
|
del self.events_in_process[event_data['id']]
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user