diff --git a/frigate/app.py b/frigate/app.py index 66d35ada2..6483e8452 100644 --- a/frigate/app.py +++ b/frigate/app.py @@ -67,6 +67,24 @@ class FrigateApp(): 'ffmpeg_pid': mp.Value('i', 0), 'frame_queue': mp.Queue(maxsize=2) } + + def check_config(self): + for name, camera in self.config.cameras.items(): + assigned_roles = list(set([r for i in camera.ffmpeg.inputs for r in i.roles])) + if not camera.save_clips.enabled and 'clips' in assigned_roles: + logger.warning(f"Camera {name} has clips assigned to an input, but save_clips is not enabled.") + elif camera.save_clips.enabled and not 'clips' in assigned_roles: + logger.warning(f"Camera {name} has save_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.") + elif camera.record.enabled and not 'record' in assigned_roles: + logger.warning(f"Camera {name} has record enabled, but record is not assigned to an input.") + + if not camera.rtmp.enabled and 'rtmp' in assigned_roles: + logger.warning(f"Camera {name} has rtmp assigned to an input, but rtmp is not enabled.") + elif camera.rtmp.enabled and not 'rtmp' in assigned_roles: + logger.warning(f"Camera {name} has rtmp enabled, but rtmp is not assigned to an input.") def set_log_levels(self): logging.getLogger().setLevel(self.config.logger.default) @@ -160,6 +178,7 @@ class FrigateApp(): logger.error(f"Error parsing config: {e}") self.log_process.terminate() sys.exit(1) + self.check_config() self.set_log_levels() self.init_queues() self.init_database() diff --git a/frigate/config.py b/frigate/config.py index b4de6b43e..6e4126b30 100644 --- a/frigate/config.py +++ b/frigate/config.py @@ -587,9 +587,13 @@ class CameraConfig(): self._ffmpeg_cmds = [] for ffmpeg_input in self._ffmpeg.inputs: + ffmpeg_cmd = self._get_ffmpeg_cmd(ffmpeg_input) + if ffmpeg_cmd is None: + continue + self._ffmpeg_cmds.append({ 'roles': ffmpeg_input.roles, - 'cmd': self._get_ffmpeg_cmd(ffmpeg_input) + 'cmd': ffmpeg_cmd }) @@ -636,6 +640,11 @@ class CameraConfig(): ffmpeg_output_args = self.ffmpeg.output_args['record'] + [ f"{os.path.join(RECORD_DIR, self.name)}-%Y%m%d%H%M%S.mp4" ] + ffmpeg_output_args + + # if there arent any outputs enabled for this input + if len(ffmpeg_output_args) == 0: + return None + return (['ffmpeg'] + ffmpeg_input.global_args + ffmpeg_input.hwaccel_args + diff --git a/frigate/test/test_config.py b/frigate/test/test_config.py index 5278dc193..9a96e9393 100644 --- a/frigate/test/test_config.py +++ b/frigate/test/test_config.py @@ -314,6 +314,31 @@ class TestConfig(TestCase): assert(len(config.cameras['back'].save_clips.objects) == 2) assert('dog' in config.cameras['back'].save_clips.objects) assert('person' in config.cameras['back'].save_clips.objects) + + def test_role_assigned_but_not_enabled(self): + json_config = { + 'mqtt': { + 'host': 'mqtt' + }, + 'cameras': { + 'back': { + 'ffmpeg': { + 'inputs': [ + { 'path': 'rtsp://10.0.0.1:554/video', 'roles': ['detect', 'rtmp'] }, + { 'path': 'rtsp://10.0.0.1:554/clips', 'roles': ['clips'] } + ] + }, + 'height': 1080, + 'width': 1920 + } + } + } + + config = FrigateConfig(config=json_config) + ffmpeg_cmds = config.cameras['back'].ffmpeg_cmds + assert(len(ffmpeg_cmds) == 1) + assert(not 'clips' in ffmpeg_cmds[0]['roles']) + if __name__ == '__main__': main(verbosity=2)