Don't save segments < 3 seconds in duration

This commit is contained in:
Nick Mowen 2023-07-24 05:57:44 -06:00
parent 761daf46ea
commit 042f2e8b34
3 changed files with 7 additions and 3 deletions

View File

@ -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."
)

View File

@ -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

View File

@ -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: