Skip to content

Commit

Permalink
make cache/clips dirs configurable
Browse files Browse the repository at this point in the history
  • Loading branch information
blakeblackshear committed Oct 18, 2020
1 parent a3cb02a commit 0fe8d48
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
2 changes: 2 additions & 0 deletions config/config.example.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
8 changes: 6 additions & 2 deletions detect_objects.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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 +
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 0fe8d48

Please sign in to comment.