Set max value for pre_capture (#8656)

This commit is contained in:
Nicolas Mowen 2023-11-18 14:37:06 -07:00 committed by GitHub
parent 977eef9138
commit 7d157dfeb0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 9 additions and 3 deletions

View File

@ -19,6 +19,7 @@ from frigate.const import (
CACHE_DIR, CACHE_DIR,
CACHE_SEGMENT_FORMAT, CACHE_SEGMENT_FORMAT,
DEFAULT_DB_PATH, DEFAULT_DB_PATH,
MAX_PRE_CAPTURE,
REGEX_CAMERA_NAME, REGEX_CAMERA_NAME,
YAML_EXT, YAML_EXT,
) )
@ -232,7 +233,9 @@ class RetainConfig(FrigateBaseModel):
class EventsConfig(FrigateBaseModel): class EventsConfig(FrigateBaseModel):
pre_capture: int = Field(default=5, title="Seconds to retain before event starts.") pre_capture: int = Field(
default=5, title="Seconds to retain before event starts.", le=MAX_PRE_CAPTURE
)
post_capture: int = Field(default=5, title="Seconds to retain after event ends.") post_capture: int = Field(default=5, title="Seconds to retain after event ends.")
required_zones: List[str] = Field( required_zones: List[str] = Field(
default_factory=list, default_factory=list,

View File

@ -51,7 +51,9 @@ DRIVER_INTEL_iHD = "iHD"
# Record Values # Record Values
CACHE_SEGMENT_FORMAT = "%Y%m%d%H%M%S%z" CACHE_SEGMENT_FORMAT = "%Y%m%d%H%M%S%z"
MAX_PRE_CAPTURE = 60
MAX_SEGMENT_DURATION = 600 MAX_SEGMENT_DURATION = 600
MAX_SEGMENTS_IN_CACHE = 6
MAX_PLAYLIST_SECONDS = 7200 # support 2 hour segments for a single playlist to account for cameras with inconsistent segment times MAX_PLAYLIST_SECONDS = 7200 # support 2 hour segments for a single playlist to account for cameras with inconsistent segment times
# Internal Comms Topics # Internal Comms Topics

View File

@ -23,6 +23,7 @@ from frigate.const import (
CACHE_SEGMENT_FORMAT, CACHE_SEGMENT_FORMAT,
INSERT_MANY_RECORDINGS, INSERT_MANY_RECORDINGS,
MAX_SEGMENT_DURATION, MAX_SEGMENT_DURATION,
MAX_SEGMENTS_IN_CACHE,
RECORD_DIR, RECORD_DIR,
) )
from frigate.models import Event, Recordings from frigate.models import Event, Recordings
@ -121,8 +122,8 @@ class RecordingMaintainer(threading.Thread):
} }
) )
# delete all cached files past the most recent 5 # delete all cached files past the most recent MAX_SEGMENTS_IN_CACHE
keep_count = 5 keep_count = MAX_SEGMENTS_IN_CACHE
for camera in grouped_recordings.keys(): for camera in grouped_recordings.keys():
# sort based on start time # sort based on start time
grouped_recordings[camera] = sorted( grouped_recordings[camera] = sorted(