mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-02-05 18:55:23 +03:00
Ensure detect height and width are not None before using them in camera configuration
This commit is contained in:
parent
cbb391160b
commit
747006cb13
@ -671,25 +671,6 @@ class CameraConfig(FrigateBaseModel):
|
|||||||
if has_rtmp:
|
if has_rtmp:
|
||||||
config["ffmpeg"]["inputs"][0]["roles"].append("rtmp")
|
config["ffmpeg"]["inputs"][0]["roles"].append("rtmp")
|
||||||
|
|
||||||
if (
|
|
||||||
config["detect"].get("height") is None
|
|
||||||
or config["detect"].get("width") is None
|
|
||||||
):
|
|
||||||
for input in config["ffmpeg"]["inputs"]:
|
|
||||||
if "detect" in input.get("roles", []):
|
|
||||||
try:
|
|
||||||
streamInfo = get_video_properties(input.get("path"))
|
|
||||||
config["detect"]["width"] = streamInfo["width"]
|
|
||||||
config["detect"]["height"] = streamInfo["height"]
|
|
||||||
break
|
|
||||||
except Exception:
|
|
||||||
config["detect"]["width"] = DEFAULT_DETECT_DIMENSIONS["width"]
|
|
||||||
config["detect"]["height"] = DEFAULT_DETECT_DIMENSIONS["height"]
|
|
||||||
logger.warn(
|
|
||||||
f"Error detecting stream resolution automatically for {input.get('path')} Applying default values."
|
|
||||||
)
|
|
||||||
continue
|
|
||||||
|
|
||||||
super().__init__(**config)
|
super().__init__(**config)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
@ -975,6 +956,29 @@ class FrigateConfig(FrigateBaseModel):
|
|||||||
{"name": name, **merged_config}
|
{"name": name, **merged_config}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
if (
|
||||||
|
camera_config.detect.height is None
|
||||||
|
or camera_config.detect.width is None
|
||||||
|
):
|
||||||
|
for input in camera_config.ffmpeg.inputs:
|
||||||
|
if "detect" in input.roles:
|
||||||
|
try:
|
||||||
|
streamInfo = get_video_properties(input.path)
|
||||||
|
camera_config.detect.width = streamInfo["width"]
|
||||||
|
camera_config.detect.height = streamInfo["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
|
||||||
|
|
||||||
# Default max_disappeared configuration
|
# Default max_disappeared configuration
|
||||||
max_disappeared = camera_config.detect.fps * 5
|
max_disappeared = camera_config.detect.fps * 5
|
||||||
if camera_config.detect.max_disappeared is None:
|
if camera_config.detect.max_disappeared is None:
|
||||||
|
|||||||
@ -1165,7 +1165,7 @@ def get_video_properties(url, get_duration=False):
|
|||||||
# Release the video stream
|
# Release the video stream
|
||||||
video.release()
|
video.release()
|
||||||
|
|
||||||
result = {"width": width, "height": height}
|
result = {"width": round(width), "height": round(height)}
|
||||||
if get_duration:
|
if get_duration:
|
||||||
# Get the frames per second (fps) of the video stream
|
# Get the frames per second (fps) of the video stream
|
||||||
fps = video.get(cv2.CAP_PROP_FPS)
|
fps = video.get(cv2.CAP_PROP_FPS)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user