From 76886ec2f77dd2d3d012f38e0cdedacdbc6481b0 Mon Sep 17 00:00:00 2001 From: Sergey Krashevich Date: Fri, 23 Jun 2023 02:52:11 +0300 Subject: [PATCH] Set detect resolution based on stream properties if available, else apply default values --- frigate/config.py | 30 ++++++++++++------------------ 1 file changed, 12 insertions(+), 18 deletions(-) diff --git a/frigate/config.py b/frigate/config.py index c9db0c112..3a6ce6b9c 100644 --- a/frigate/config.py +++ b/frigate/config.py @@ -959,30 +959,24 @@ class FrigateConfig(FrigateBaseModel): ): for input in camera_config.ffmpeg.inputs: if "detect" in input.roles: + stream_info = {"width": 0, "height": 0} try: stream_info = get_video_properties(input.path) - camera_config.detect.width = ( - stream_info["width"] - if stream_info["width"] > 0 - else DEFAULT_DETECT_DIMENSIONS["width"] - ) - camera_config.detect.height = ( - stream_info["height"] - if stream_info["height"] > 0 - else DEFAULT_DETECT_DIMENSIONS["height"] - ) - break except Exception: - camera_config.detect.width = DEFAULT_DETECT_DIMENSIONS[ - "width" - ] - camera_config.detect.height = DEFAULT_DETECT_DIMENSIONS[ - "height" - ] logger.warn( f"Error detecting stream resolution automatically for {input.path} Applying default values." ) - continue + + camera_config.detect.width = ( + stream_info["width"] + if stream_info["width"] > 0 + else DEFAULT_DETECT_DIMENSIONS["width"] + ) + camera_config.detect.height = ( + stream_info["height"] + if stream_info["height"] > 0 + else DEFAULT_DETECT_DIMENSIONS["height"] + ) # Default max_disappeared configuration max_disappeared = camera_config.detect.fps * 5