Skip to content

NVR with realtime local object detection for IP cameras

Improve default timelapse args and make timelapse customizable (#7840)

Nicolas Mowen7d0216b8fb43
diff --git a/docs/docs/configuration/index.md b/docs/docs/configuration/index.md
index ad52e7972e..874a77cda6 100644
--- a/docs/docs/configuration/index.md
+++ b/docs/docs/configuration/index.md
@@ -362,6 +362,16 @@ record:
# active_objects - save all recording segments with active/moving objects
# NOTE: this mode only applies when the days setting above is greater than 0
mode: all
+ # Optional: Recording Export Settings
+ export:
+ # Optional: Timelapse Output Args (default: shown below).
+ # NOTE: The default args are set to fit 24 hours of recording into 1 hour playback.
+ # See https://stackoverflow.com/a/58268695 for more info on how these args work.
+ # As an example: if you wanted to go from 24 hours to 30 minutes that would be going
+ # from 86400 seconds to 1800 seconds which would be 1800 / 86400 = 0.02.
+ # The -r (framerate) dictates how smooth the output video is.
+ # So the args would be -vf setpts=0.02*PTS -r 30 in that case.
+ timelapse_args: "-vf setpts=0.04*PTS -r 30"
# Optional: Event recording settings
events:
# Optional: Number of seconds before the event to include (default: shown below)
diff --git a/frigate/config.py b/frigate/config.py
index dc99029025..ba8a112f18 100644
--- a/frigate/config.py
+++ b/frigate/config.py
@@ -51,6 +51,7 @@ DEFAULT_TRACKED_OBJECTS = ["person"]
DEFAULT_LISTEN_AUDIO = ["bark", "fire_alarm", "scream", "speech", "yell"]
DEFAULT_DETECTORS = {"cpu": {"type": "cpu"}}
DEFAULT_DETECT_DIMENSIONS = {"width": 1280, "height": 720}
+DEFAULT_TIME_LAPSE_FFMPEG_ARGS = "-vf setpts=0.04*PTS -r 30"
class FrigateBaseModel(BaseModel):
@@ -198,6 +199,12 @@ class RecordRetainConfig(FrigateBaseModel):
mode: RetainModeEnum = Field(default=RetainModeEnum.all, title="Retain mode.")
+class RecordExportConfig(FrigateBaseModel):
+ timelapse_args: str = Field(
+ default=DEFAULT_TIME_LAPSE_FFMPEG_ARGS, title="Timelapse Args"
+ )
+
+
class RecordConfig(FrigateBaseModel):
enabled: bool = Field(default=False, title="Enable record on all cameras.")
sync_on_startup: bool = Field(
@@ -213,6 +220,9 @@ class RecordConfig(FrigateBaseModel):
events: EventsConfig = Field(
default_factory=EventsConfig, title="Event specific settings."
)
+ export: RecordExportConfig = Field(
+ default_factory=RecordExportConfig, title="Recording Export Config"
+ )
enabled_in_config: Optional[bool] = Field(
title="Keep track of original state of recording."
)
diff --git a/frigate/record/export.py b/frigate/record/export.py
index bfa47a07ef..2e5de61c55 100644
--- a/frigate/record/export.py
+++ b/frigate/record/export.py
@@ -18,6 +18,9 @@ from frigate.models import Recordings
logger = logging.getLogger(__name__)
+TIMELAPSE_DATA_INPUT_ARGS = "-an -skip_frame nokey"
+
+
def lower_priority():
os.nice(10)
@@ -99,8 +102,8 @@ class RecordingExporter(threading.Thread):
ffmpeg_cmd = (
parse_preset_hardware_acceleration_encode(
self.config.ffmpeg.hwaccel_args,
- ffmpeg_input,
- f"-vf setpts=0.04*PTS -r 30 -an {file_name}",
+ f"{TIMELAPSE_DATA_INPUT_ARGS} {ffmpeg_input}",
+ f"{self.config.cameras[self.camera].record.export.timelapse_args} {file_name}",
EncodeTypeEnum.timelapse,
)
).split(" ")