Add config option for chapters

This commit is contained in:
Nicolas Mowen 2026-06-09 07:54:56 -06:00
parent f10605b53c
commit ee787f54cb
3 changed files with 20 additions and 10 deletions

View File

@ -31,7 +31,6 @@ from frigate.api.defs.tags import Tags
from frigate.const import CLIPS_DIR, EXPORT_DIR from frigate.const import CLIPS_DIR, EXPORT_DIR
from frigate.models import Export, Previews, Recordings from frigate.models import Export, Previews, Recordings
from frigate.record.export import ( from frigate.record.export import (
ChaptersEnum,
PlaybackFactorEnum, PlaybackFactorEnum,
PlaybackSourceEnum, PlaybackSourceEnum,
RecordingExporter, RecordingExporter,
@ -94,6 +93,14 @@ def export_recording(
friendly_name = body.name friendly_name = body.name
existing_image = sanitize_filepath(body.image_path) if body.image_path else None existing_image = sanitize_filepath(body.image_path) if body.image_path else None
# a chapters value in the request body overrides the camera's export config
camera_config = request.app.frigate_config.cameras[camera_name]
chapters = (
body.chapters
if body.chapters is not None
else camera_config.record.export.chapters
)
# Ensure that existing_image is a valid path # Ensure that existing_image is a valid path
if existing_image and not existing_image.startswith(CLIPS_DIR): if existing_image and not existing_image.startswith(CLIPS_DIR):
return JSONResponse( return JSONResponse(
@ -162,7 +169,7 @@ def export_recording(
if playback_source in PlaybackSourceEnum.__members__.values() if playback_source in PlaybackSourceEnum.__members__.values()
else PlaybackSourceEnum.recordings else PlaybackSourceEnum.recordings
), ),
chapters=ChaptersEnum(body.chapters) if body.chapters else None, chapters=chapters,
) )
exporter.start() exporter.start()
return JSONResponse( return JSONResponse(

View File

@ -9,6 +9,7 @@ from frigate.review.types import SeverityEnum
from ..base import FrigateBaseModel from ..base import FrigateBaseModel
__all__ = [ __all__ = [
"ChaptersEnum",
"RecordConfig", "RecordConfig",
"RecordExportConfig", "RecordExportConfig",
"RecordPreviewConfig", "RecordPreviewConfig",
@ -66,10 +67,19 @@ class RecordPreviewConfig(FrigateBaseModel):
) )
class ChaptersEnum(str, Enum):
none = "none"
recording_segments = "recording_segments"
class RecordExportConfig(FrigateBaseModel): class RecordExportConfig(FrigateBaseModel):
timelapse_args: str = Field( timelapse_args: str = Field(
default=DEFAULT_TIME_LAPSE_FFMPEG_ARGS, title="Timelapse Args" default=DEFAULT_TIME_LAPSE_FFMPEG_ARGS, title="Timelapse Args"
) )
chapters: ChaptersEnum = Field(
default=ChaptersEnum.none,
title="Chapter metadata to embed in exported recordings",
)
class RecordConfig(FrigateBaseModel): class RecordConfig(FrigateBaseModel):

View File

@ -16,6 +16,7 @@ import pytz
from peewee import DoesNotExist from peewee import DoesNotExist
from frigate.config import FfmpegConfig, FrigateConfig from frigate.config import FfmpegConfig, FrigateConfig
from frigate.config.camera.record import ChaptersEnum
from frigate.const import ( from frigate.const import (
CACHE_DIR, CACHE_DIR,
CLIPS_DIR, CLIPS_DIR,
@ -51,14 +52,6 @@ class PlaybackSourceEnum(str, Enum):
preview = "preview" preview = "preview"
class ChaptersEnum(str, Enum):
# One chapter per recording segment, titled with the segment's
# wallclock start time in strict ISO 8601 form. Lets viewers map
# output playback time back to wallclock without reading a timestamp
# overlay via OCR.
recording_segments = "recording_segments"
class RecordingExporter(threading.Thread): class RecordingExporter(threading.Thread):
"""Exports a specific set of recordings for a camera to storage as a single file.""" """Exports a specific set of recordings for a camera to storage as a single file."""