forked from Github/frigate
clean house on clips
This commit is contained in:
@@ -90,15 +90,6 @@ class FrigateApp:
|
||||
assigned_roles = list(
|
||||
set([r for i in camera.ffmpeg.inputs for r in i.roles])
|
||||
)
|
||||
if not camera.clips.enabled and "clips" in assigned_roles:
|
||||
logger.warning(
|
||||
f"Camera {name} has clips assigned to an input, but clips is not enabled."
|
||||
)
|
||||
elif camera.clips.enabled and not "clips" in assigned_roles:
|
||||
logger.warning(
|
||||
f"Camera {name} has clips enabled, but clips is not assigned to an input."
|
||||
)
|
||||
|
||||
if not camera.record.enabled and "record" in assigned_roles:
|
||||
logger.warning(
|
||||
f"Camera {name} has record assigned to an input, but record is not enabled."
|
||||
|
||||
@@ -445,7 +445,6 @@ class CameraConfig(BaseModel):
|
||||
zones: Dict[str, ZoneConfig] = Field(
|
||||
default_factory=dict, title="Zone configuration."
|
||||
)
|
||||
clips: ClipsConfig = Field(default_factory=ClipsConfig, title="Clip configuration.")
|
||||
record: RecordConfig = Field(
|
||||
default_factory=RecordConfig, title="Record configuration."
|
||||
)
|
||||
@@ -526,9 +525,7 @@ class CameraConfig(BaseModel):
|
||||
ffmpeg_output_args = (
|
||||
rtmp_args + [f"rtmp://127.0.0.1/live/{self.name}"] + ffmpeg_output_args
|
||||
)
|
||||
if any(role in ["clips", "record"] for role in ffmpeg_input.roles) and (
|
||||
self.record.enabled or self.clips.enabled
|
||||
):
|
||||
if "record" in ffmpeg_input.roles and self.record.enabled:
|
||||
record_args = (
|
||||
self.ffmpeg.output_args.record
|
||||
if isinstance(self.ffmpeg.output_args.record, list)
|
||||
@@ -638,9 +635,6 @@ class FrigateConfig(BaseModel):
|
||||
logger: LoggerConfig = Field(
|
||||
default_factory=LoggerConfig, title="Logging configuration."
|
||||
)
|
||||
clips: ClipsConfig = Field(
|
||||
default_factory=ClipsConfig, title="Global clips configuration."
|
||||
)
|
||||
record: RecordConfig = Field(
|
||||
default_factory=RecordConfig, title="Global record configuration."
|
||||
)
|
||||
@@ -676,7 +670,6 @@ class FrigateConfig(BaseModel):
|
||||
# Global config to propegate down to camera level
|
||||
global_config = config.dict(
|
||||
include={
|
||||
"clips": ...,
|
||||
"record": ...,
|
||||
"snapshots": ...,
|
||||
"objects": ...,
|
||||
@@ -751,21 +744,6 @@ class FrigateConfig(BaseModel):
|
||||
|
||||
config.cameras[name] = camera_config
|
||||
|
||||
# Merge Clips configuration for backward compatibility
|
||||
if camera_config.clips.enabled:
|
||||
logger.warn(
|
||||
"Clips configuration is deprecated. Configure clip settings under record -> events."
|
||||
)
|
||||
if not camera_config.record.enabled:
|
||||
camera_config.record.enabled = True
|
||||
camera_config.record.retain_days = 0
|
||||
camera_config.record.events = ClipsConfig.parse_obj(
|
||||
deep_merge(
|
||||
camera_config.clips.dict(exclude_unset=True),
|
||||
camera_config.record.events.dict(exclude_unset=True),
|
||||
)
|
||||
)
|
||||
|
||||
return config
|
||||
|
||||
@validator("cameras")
|
||||
|
||||
@@ -349,7 +349,9 @@ class TestConfig(unittest.TestCase):
|
||||
def test_inherit_clips_retention(self):
|
||||
config = {
|
||||
"mqtt": {"host": "mqtt"},
|
||||
"clips": {"retain": {"default": 20, "objects": {"person": 30}}},
|
||||
"record": {
|
||||
"events": {"retain": {"default": 20, "objects": {"person": 30}}}
|
||||
},
|
||||
"cameras": {
|
||||
"back": {
|
||||
"ffmpeg": {
|
||||
@@ -369,12 +371,16 @@ class TestConfig(unittest.TestCase):
|
||||
assert config == frigate_config.dict(exclude_unset=True)
|
||||
|
||||
runtime_config = frigate_config.runtime_config
|
||||
assert runtime_config.cameras["back"].clips.retain.objects["person"] == 30
|
||||
assert (
|
||||
runtime_config.cameras["back"].record.events.retain.objects["person"] == 30
|
||||
)
|
||||
|
||||
def test_roles_listed_twice_throws_error(self):
|
||||
config = {
|
||||
"mqtt": {"host": "mqtt"},
|
||||
"clips": {"retain": {"default": 20, "objects": {"person": 30}}},
|
||||
"record": {
|
||||
"events": {"retain": {"default": 20, "objects": {"person": 30}}}
|
||||
},
|
||||
"cameras": {
|
||||
"back": {
|
||||
"ffmpeg": {
|
||||
@@ -396,7 +402,9 @@ class TestConfig(unittest.TestCase):
|
||||
def test_zone_matching_camera_name_throws_error(self):
|
||||
config = {
|
||||
"mqtt": {"host": "mqtt"},
|
||||
"clips": {"retain": {"default": 20, "objects": {"person": 30}}},
|
||||
"record": {
|
||||
"events": {"retain": {"default": 20, "objects": {"person": 30}}}
|
||||
},
|
||||
"cameras": {
|
||||
"back": {
|
||||
"ffmpeg": {
|
||||
@@ -418,7 +426,9 @@ class TestConfig(unittest.TestCase):
|
||||
def test_zone_assigns_color_and_contour(self):
|
||||
config = {
|
||||
"mqtt": {"host": "mqtt"},
|
||||
"clips": {"retain": {"default": 20, "objects": {"person": 30}}},
|
||||
"record": {
|
||||
"events": {"retain": {"default": 20, "objects": {"person": 30}}}
|
||||
},
|
||||
"cameras": {
|
||||
"back": {
|
||||
"ffmpeg": {
|
||||
@@ -447,7 +457,9 @@ class TestConfig(unittest.TestCase):
|
||||
def test_clips_should_default_to_global_objects(self):
|
||||
config = {
|
||||
"mqtt": {"host": "mqtt"},
|
||||
"clips": {"retain": {"default": 20, "objects": {"person": 30}}},
|
||||
"record": {
|
||||
"events": {"retain": {"default": 20, "objects": {"person": 30}}}
|
||||
},
|
||||
"objects": {"track": ["person", "dog"]},
|
||||
"cameras": {
|
||||
"back": {
|
||||
@@ -461,7 +473,7 @@ class TestConfig(unittest.TestCase):
|
||||
"width": 1920,
|
||||
"fps": 5,
|
||||
},
|
||||
"clips": {"enabled": True},
|
||||
"record": {"events": {"enabled": True}},
|
||||
}
|
||||
},
|
||||
}
|
||||
@@ -470,8 +482,8 @@ class TestConfig(unittest.TestCase):
|
||||
|
||||
runtime_config = frigate_config.runtime_config
|
||||
back_camera = runtime_config.cameras["back"]
|
||||
assert back_camera.clips.objects is None
|
||||
assert back_camera.clips.retain.objects["person"] == 30
|
||||
assert back_camera.record.events.objects is None
|
||||
assert back_camera.record.events.retain.objects["person"] == 30
|
||||
|
||||
def test_role_assigned_but_not_enabled(self):
|
||||
config = {
|
||||
|
||||
Reference in New Issue
Block a user