From 0fe8d486d98a0e3fdd079ad0290fc66c04befc1b Mon Sep 17 00:00:00 2001 From: Blake Blackshear Date: Sun, 18 Oct 2020 10:57:52 -0500 Subject: [PATCH] make cache/clips dirs configurable --- config/config.example.yml | 2 ++ detect_objects.py | 8 ++++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/config/config.example.yml b/config/config.example.yml index 2e48ba62fe..b156af87ca 100644 --- a/config/config.example.yml +++ b/config/config.example.yml @@ -31,6 +31,8 @@ save_clips: # will begin to expire and the resulting clip will be the last x seconds of the event. ########### max_seconds: 300 + clips_dir: /clips + cache_dir: /cache ################# # Default ffmpeg args. Optional and can be overwritten per camera. diff --git a/detect_objects.py b/detect_objects.py index 71eaf82225..9668015a9c 100644 --- a/detect_objects.py +++ b/detect_objects.py @@ -214,6 +214,7 @@ def on_connect(client, userdata, flags, rc): if not config.get('fps') is None: ffmpeg_output_args = ["-r", str(config.get('fps'))] + ffmpeg_output_args if config.get('save_clips', {}).get('enabled', False): + cache_dir = config.get('save_clips', {}).get('cache_dir', '/cache') ffmpeg_output_args = [ "-f", "segment", @@ -230,7 +231,7 @@ def on_connect(client, userdata, flags, rc): "-an", "-map", "0", - f"/cache/{name}-%Y%m%d%H%M%S.mp4" + f"{os.path.join(cache_dir, name)}-%Y%m%d%H%M%S.mp4" ] + ffmpeg_output_args ffmpeg_cmd = (['ffmpeg'] + ffmpeg_global_args + @@ -296,7 +297,10 @@ def on_connect(client, userdata, flags, rc): camera_process['process'].start() print(f"Camera_process started for {name}: {camera_process['process'].pid}") - event_processor = EventProcessor(CONFIG, camera_processes, '/cache', '/clips', event_queue, stop_event) + + cache_dir = config.get('save_clips', {}).get('cache_dir', '/cache') + clips_dir = config.get('save_clips', {}).get('clips_dir', '/clips') + event_processor = EventProcessor(CONFIG, camera_processes, cache_dir, clips_dir, event_queue, stop_event) event_processor.start() object_processor = TrackedObjectProcessor(CONFIG['cameras'], client, MQTT_TOPIC_PREFIX, tracked_objects_queue, event_queue, stop_event)