mirror of
https://github.com/blakeblackshear/frigate.git
synced 2025-01-02 00:07:11 +01:00
make pre_capture time configurable
This commit is contained in:
parent
6dc7b8f246
commit
a8c0fadf95
@ -125,7 +125,12 @@ cameras:
|
||||
# WARNING: Videos in /cache are retained until there are no ongoing events. If you are tracking cars or
|
||||
# other objects for long periods of time, the cache will continue to grow indefinitely.
|
||||
################
|
||||
save_clips: False
|
||||
save_clips:
|
||||
enabled: False
|
||||
#########
|
||||
# Number of seconds before the event to include in the clips
|
||||
#########
|
||||
pre_capture: 30
|
||||
|
||||
################
|
||||
# Configuration for the snapshots in the debug view and mqtt
|
||||
|
@ -193,7 +193,7 @@ def main():
|
||||
ffmpeg_hwaccel_args = ffmpeg.get('hwaccel_args', FFMPEG_DEFAULT_CONFIG['hwaccel_args'])
|
||||
ffmpeg_input_args = ffmpeg.get('input_args', FFMPEG_DEFAULT_CONFIG['input_args'])
|
||||
ffmpeg_output_args = ffmpeg.get('output_args', FFMPEG_DEFAULT_CONFIG['output_args'])
|
||||
if config.get('save_clips', False):
|
||||
if config.get('save_clips', {}).get('enabled', False):
|
||||
ffmpeg_output_args = [
|
||||
"-f",
|
||||
"segment",
|
||||
|
@ -78,7 +78,7 @@ class EventProcessor(threading.Thread):
|
||||
del self.cached_clips[f]
|
||||
os.remove(os.path.join(self.cache_dir,f))
|
||||
|
||||
def create_clip(self, camera, event_data):
|
||||
def create_clip(self, camera, event_data, pre_capture):
|
||||
# get all clips from the camera with the event sorted
|
||||
sorted_clips = sorted([c for c in self.cached_clips.values() if c['camera'] == camera], key = lambda i: i['start_time'])
|
||||
|
||||
@ -88,7 +88,7 @@ class EventProcessor(threading.Thread):
|
||||
# get all clips from the camera with the event sorted
|
||||
sorted_clips = sorted([c for c in self.cached_clips.values() if c['camera'] == camera], key = lambda i: i['start_time'])
|
||||
|
||||
playlist_start = event_data['start_time']-30
|
||||
playlist_start = event_data['start_time']-pre_capture
|
||||
playlist_end = event_data['end_time']+5
|
||||
playlist_lines = []
|
||||
for clip in sorted_clips:
|
||||
@ -145,8 +145,8 @@ class EventProcessor(threading.Thread):
|
||||
self.events_in_process[event_data['id']] = event_data
|
||||
|
||||
if event_type == 'end':
|
||||
if self.config[camera].get('save_clips', False) and len(self.cached_clips) > 0:
|
||||
self.create_clip(camera, event_data)
|
||||
if self.config[camera].get('save_clips', {}).get('enabled', False) and len(self.cached_clips) > 0:
|
||||
self.create_clip(camera, event_data, self.config[camera].get('save_clips', {}).get('pre_capture', 30))
|
||||
del self.events_in_process[event_data['id']]
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user