mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-02-13 22:55:26 +03:00
Refactor recordings config to be based off of review items
This commit is contained in:
parent
cf7718132a
commit
20ba0a5142
@ -296,12 +296,9 @@ class RetainModeEnum(str, Enum):
|
|||||||
active_objects = "active_objects"
|
active_objects = "active_objects"
|
||||||
|
|
||||||
|
|
||||||
class RetainConfig(FrigateBaseModel):
|
class RecordRetainConfig(FrigateBaseModel):
|
||||||
default: float = Field(default=10, title="Default retention period.")
|
days: float = Field(default=0, title="Default retention period.")
|
||||||
mode: RetainModeEnum = Field(default=RetainModeEnum.motion, title="Retain mode.")
|
mode: RetainModeEnum = Field(default=RetainModeEnum.all, title="Retain mode.")
|
||||||
objects: Dict[str, float] = Field(
|
|
||||||
default_factory=dict, title="Object retention period."
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
class EventsConfig(FrigateBaseModel):
|
class EventsConfig(FrigateBaseModel):
|
||||||
@ -309,18 +306,9 @@ class EventsConfig(FrigateBaseModel):
|
|||||||
default=5, title="Seconds to retain before event starts.", le=MAX_PRE_CAPTURE
|
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.")
|
||||||
objects: Optional[List[str]] = Field(
|
retain: RecordRetainConfig = Field(
|
||||||
None,
|
default_factory=RecordRetainConfig, title="Event retention settings."
|
||||||
title="List of objects to be detected in order to save the event.",
|
|
||||||
)
|
)
|
||||||
retain: RetainConfig = Field(
|
|
||||||
default_factory=RetainConfig, title="Event retention settings."
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
class RecordRetainConfig(FrigateBaseModel):
|
|
||||||
days: float = Field(default=0, title="Default retention period.")
|
|
||||||
mode: RetainModeEnum = Field(default=RetainModeEnum.all, title="Retain mode.")
|
|
||||||
|
|
||||||
|
|
||||||
class RecordExportConfig(FrigateBaseModel):
|
class RecordExportConfig(FrigateBaseModel):
|
||||||
@ -355,8 +343,11 @@ class RecordConfig(FrigateBaseModel):
|
|||||||
retain: RecordRetainConfig = Field(
|
retain: RecordRetainConfig = Field(
|
||||||
default_factory=RecordRetainConfig, title="Record retention settings."
|
default_factory=RecordRetainConfig, title="Record retention settings."
|
||||||
)
|
)
|
||||||
events: EventsConfig = Field(
|
detections: EventsConfig = Field(
|
||||||
default_factory=EventsConfig, title="Event specific settings."
|
default_factory=EventsConfig, title="Detection specific retention settings."
|
||||||
|
)
|
||||||
|
alerts: EventsConfig = Field(
|
||||||
|
default_factory=EventsConfig, title="Alert specific retention settings."
|
||||||
)
|
)
|
||||||
export: RecordExportConfig = Field(
|
export: RecordExportConfig = Field(
|
||||||
default_factory=RecordExportConfig, title="Recording Export Config"
|
default_factory=RecordExportConfig, title="Recording Export Config"
|
||||||
@ -924,6 +915,14 @@ class CameraFfmpegConfig(FfmpegConfig):
|
|||||||
return v
|
return v
|
||||||
|
|
||||||
|
|
||||||
|
class RetainConfig(FrigateBaseModel):
|
||||||
|
default: float = Field(default=10, title="Default retention period.")
|
||||||
|
mode: RetainModeEnum = Field(default=RetainModeEnum.motion, title="Retain mode.")
|
||||||
|
objects: Dict[str, float] = Field(
|
||||||
|
default_factory=dict, title="Object retention period."
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
class SnapshotsConfig(FrigateBaseModel):
|
class SnapshotsConfig(FrigateBaseModel):
|
||||||
enabled: bool = Field(default=False, title="Snapshots enabled.")
|
enabled: bool = Field(default=False, title="Snapshots enabled.")
|
||||||
clean_copy: bool = Field(
|
clean_copy: bool = Field(
|
||||||
|
|||||||
@ -13,7 +13,7 @@ from frigate.util.services import get_video_properties
|
|||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
CURRENT_CONFIG_VERSION = 0.14
|
CURRENT_CONFIG_VERSION = "0.14.1-0"
|
||||||
|
|
||||||
|
|
||||||
def migrate_frigate_config(config_file: str):
|
def migrate_frigate_config(config_file: str):
|
||||||
@ -29,7 +29,7 @@ def migrate_frigate_config(config_file: str):
|
|||||||
with open(config_file, "r") as f:
|
with open(config_file, "r") as f:
|
||||||
config: dict[str, dict[str, any]] = yaml.load(f)
|
config: dict[str, dict[str, any]] = yaml.load(f)
|
||||||
|
|
||||||
previous_version = config.get("version", 0.13)
|
previous_version = str(config.get("version", "0.13"))
|
||||||
|
|
||||||
if previous_version == CURRENT_CONFIG_VERSION:
|
if previous_version == CURRENT_CONFIG_VERSION:
|
||||||
logger.info("frigate config does not need migration...")
|
logger.info("frigate config does not need migration...")
|
||||||
@ -38,12 +38,12 @@ def migrate_frigate_config(config_file: str):
|
|||||||
logger.info("copying config as backup...")
|
logger.info("copying config as backup...")
|
||||||
shutil.copy(config_file, os.path.join(CONFIG_DIR, "backup_config.yaml"))
|
shutil.copy(config_file, os.path.join(CONFIG_DIR, "backup_config.yaml"))
|
||||||
|
|
||||||
if previous_version < 0.14:
|
if previous_version < "0.14":
|
||||||
logger.info(f"Migrating frigate config from {previous_version} to 0.14...")
|
logger.info(f"Migrating frigate config from {previous_version} to 0.14...")
|
||||||
new_config = migrate_014(config)
|
new_config = migrate_014(config)
|
||||||
with open(config_file, "w") as f:
|
with open(config_file, "w") as f:
|
||||||
yaml.dump(new_config, f)
|
yaml.dump(new_config, f)
|
||||||
previous_version = 0.14
|
previous_version = "0.14"
|
||||||
|
|
||||||
logger.info("Migrating export file names...")
|
logger.info("Migrating export file names...")
|
||||||
for file in os.listdir(EXPORT_DIR):
|
for file in os.listdir(EXPORT_DIR):
|
||||||
@ -55,6 +55,9 @@ def migrate_frigate_config(config_file: str):
|
|||||||
os.path.join(EXPORT_DIR, file), os.path.join(EXPORT_DIR, new_name)
|
os.path.join(EXPORT_DIR, file), os.path.join(EXPORT_DIR, new_name)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
if previous_version < "0.14.1-0":
|
||||||
|
logger.info(f"Migrating frigate config from {previous_version} to 0.14...")
|
||||||
|
|
||||||
logger.info("Finished frigate config migration...")
|
logger.info("Finished frigate config migration...")
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user