Skip to content

Commit

Permalink
fix rtmp again
Browse files Browse the repository at this point in the history
  • Loading branch information
blakeblackshear committed Oct 24, 2021
1 parent 76142e9 commit 26ae608
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 13 deletions.
25 changes: 12 additions & 13 deletions frigate/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -792,22 +792,21 @@ def runtime_config(self) -> FrigateConfig:
**camera_config.motion.dict(exclude_unset=True),
)

config.cameras[name] = camera_config

# check runtime config
for name, camera in config.cameras.items():
assigned_roles = list(
set([r for i in camera.ffmpeg.inputs for r in i.roles])
assigned_roles = list(
set([r for i in camera_config.ffmpeg.inputs for r in i.roles])
)
if camera_config.record.enabled and not "record" in assigned_roles:
raise ValueError(
f"Camera {name} has record enabled, but record is not assigned to an input."
)
if camera.record.enabled and not "record" in assigned_roles:
raise ValueError(
f"Camera {name} has record enabled, but record is not assigned to an input."
)

if camera.rtmp.enabled and not "rtmp" in assigned_roles:
raise ValueError(
f"Camera {name} has rtmp enabled, but rtmp is not assigned to an input."
)
if camera_config.rtmp.enabled and not "rtmp" in assigned_roles:
raise ValueError(
f"Camera {name} has rtmp enabled, but rtmp is not assigned to an input."
)

config.cameras[name] = camera_config

return config

Expand Down
50 changes: 50 additions & 0 deletions frigate/test/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -752,6 +752,56 @@ def test_fails_on_missing_role(self):
frigate_config = FrigateConfig(**config)
self.assertRaises(ValueError, lambda: frigate_config.runtime_config)

def test_works_on_missing_role_multiple_cams(self):

config = {
"mqtt": {"host": "mqtt"},
"rtmp": {"enabled": False},
"cameras": {
"back": {
"ffmpeg": {
"inputs": [
{
"path": "rtsp:https://10.0.0.1:554/video",
"roles": ["detect"],
},
{
"path": "rtsp:https://10.0.0.1:554/video2",
"roles": ["record"],
},
]
},
"detect": {
"height": 1080,
"width": 1920,
"fps": 5,
},
},
"cam2": {
"ffmpeg": {
"inputs": [
{
"path": "rtsp:https://10.0.0.1:554/video",
"roles": ["detect"],
},
{
"path": "rtsp:https://10.0.0.1:554/video2",
"roles": ["record"],
},
]
},
"detect": {
"height": 1080,
"width": 1920,
"fps": 5,
},
},
},
}

frigate_config = FrigateConfig(**config)
runtime_config = frigate_config.runtime_config

def test_global_detect(self):

config = {
Expand Down

0 comments on commit 26ae608

Please sign in to comment.