From 042f2e8b3451db3ab59dc828ccab3c7764ab9b42 Mon Sep 17 00:00:00 2001 From: Nick Mowen Date: Mon, 24 Jul 2023 05:57:44 -0600 Subject: [PATCH] Don't save segments < 3 seconds in duration --- frigate/config.py | 6 ++++-- frigate/const.py | 1 + frigate/record/maintainer.py | 3 ++- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/frigate/config.py b/frigate/config.py index 7f1624ed4..4aa2fa5fd 100644 --- a/frigate/config.py +++ b/frigate/config.py @@ -16,6 +16,7 @@ from frigate.const import ( AUDIO_MIN_CONFIDENCE, CACHE_DIR, DEFAULT_DB_PATH, + MIN_SEGMENT_DURATION, REGEX_CAMERA_NAME, YAML_EXT, ) @@ -931,9 +932,10 @@ def verify_recording_segments_setup_with_reasonable_time( f"Camera {camera_config.name} has no segment_time in recording output args, segment args are required for record." ) - if int(record_args[seg_arg_index + 1]) > 60: + config_duration = int(record_args[seg_arg_index + 1]) + if config_duration < MIN_SEGMENT_DURATION or config_duration > 60: raise ValueError( - f"Camera {camera_config.name} has invalid segment_time output arg, segment_time must be 60 or less." + f"Camera {camera_config.name} has invalid segment_time output arg, segment_time must be {MIN_SEGMENT_DURATION} <= x <= 60." ) diff --git a/frigate/const.py b/frigate/const.py index c6912471b..40734fb95 100644 --- a/frigate/const.py +++ b/frigate/const.py @@ -45,6 +45,7 @@ DRIVER_INTEL_iHD = "iHD" # Record Values +MIN_SEGMENT_DURATION = 3 MAX_SEGMENT_DURATION = 600 MAX_PLAYLIST_SECONDS = 7200 # support 2 hour segments for a single playlist to account for cameras with inconsistent segment times diff --git a/frigate/record/maintainer.py b/frigate/record/maintainer.py index c67f07c80..262f03f1b 100644 --- a/frigate/record/maintainer.py +++ b/frigate/record/maintainer.py @@ -22,6 +22,7 @@ from frigate.const import ( CACHE_DIR, INSERT_MANY_RECORDINGS, MAX_SEGMENT_DURATION, + MIN_SEGMENT_DURATION, RECORD_DIR, ) from frigate.models import Event, Recordings @@ -199,7 +200,7 @@ class RecordingMaintainer(threading.Thread): duration = -1 # ensure duration is within expected length - if 0 < duration < MAX_SEGMENT_DURATION: + if MIN_SEGMENT_DURATION < duration < MAX_SEGMENT_DURATION: end_time = start_time + datetime.timedelta(seconds=duration) self.end_time_cache[cache_path] = (end_time, duration) else: