mirror of
https://github.com/blakeblackshear/frigate.git
synced 2025-07-26 13:47:03 +02:00
Feature: automatic camera resolution configuration (#6810)
* Add auto configuration for height, width and fps in detect role
* Add auto-configuration for detect width, height, and fps for input roles with detect in the CameraConfig class in config.py
* Refactor code to retrieve video properties from input stream in CameraConfig class and add optional parameter to retrieve video duration in get_video_properties function
* format
* Set default detect dimensions to 1280x720 and update DetectConfig to use the defaults
* Revert "Set default detect dimensions to 1280x720 and update DetectConfig to use the defaults"
This reverts commit a1aed0414d
.
* Add default detect dimensions if autoconfiguration failed and log a warning message
* fix warn message spelling on frigate/config.py
Co-authored-by: Nicolas Mowen <nickmowen213@gmail.com>
* Ensure detect height and width are not None before using them in camera configuration
* docs: initial commit
* rename streamInfo to stream_info
Co-authored-by: Blake Blackshear <blakeb@blakeshome.com>
* Apply suggestions from code review
Co-authored-by: Nicolas Mowen <nickmowen213@gmail.com>
* Update docs
* handle case then get_video_properties returns 0x0 dimension
* Set detect resolution based on stream properties if available, else apply default values
* Update FrigateConfig to set default values for stream_info if resolution detection fails
* Update camera detection dimensions based on stream information if available
---------
Co-authored-by: Nicolas Mowen <nickmowen213@gmail.com>
Co-authored-by: Blake Blackshear <blakeb@blakeshome.com>
This commit is contained in:
parent
6ac36e8436
commit
ce3a544ecd
@ -80,8 +80,8 @@ cameras:
|
|||||||
rtmp:
|
rtmp:
|
||||||
enabled: False # <-- RTMP should be disabled if your stream is not H264
|
enabled: False # <-- RTMP should be disabled if your stream is not H264
|
||||||
detect:
|
detect:
|
||||||
width: # <---- update for your camera's resolution
|
width: # <- optional, by default Frigate tries to automatically detect resolution
|
||||||
height: # <---- update for your camera's resolution
|
height: # <- optional, by default Frigate tries to automatically detect resolution
|
||||||
```
|
```
|
||||||
|
|
||||||
### Blue Iris RTSP Cameras
|
### Blue Iris RTSP Cameras
|
||||||
|
@ -33,8 +33,8 @@ cameras:
|
|||||||
roles:
|
roles:
|
||||||
- record
|
- record
|
||||||
detect:
|
detect:
|
||||||
width: 1280
|
width: 1280 # <- optional, by default Frigate tries to automatically detect resolution
|
||||||
height: 720
|
height: 720 # <- optional, by default Frigate tries to automatically detect resolution
|
||||||
```
|
```
|
||||||
|
|
||||||
Additional cameras are simply added to the config under the `cameras` entry.
|
Additional cameras are simply added to the config under the `cameras` entry.
|
||||||
|
@ -19,9 +19,6 @@ cameras:
|
|||||||
- path: rtsp://viewer:{FRIGATE_RTSP_PASSWORD}@10.0.10.10:554/cam/realmonitor?channel=1&subtype=2
|
- path: rtsp://viewer:{FRIGATE_RTSP_PASSWORD}@10.0.10.10:554/cam/realmonitor?channel=1&subtype=2
|
||||||
roles:
|
roles:
|
||||||
- detect
|
- detect
|
||||||
detect:
|
|
||||||
width: 1280
|
|
||||||
height: 720
|
|
||||||
```
|
```
|
||||||
|
|
||||||
### VSCode Configuration Schema
|
### VSCode Configuration Schema
|
||||||
|
@ -68,10 +68,6 @@ cameras:
|
|||||||
input_args: -re -stream_loop -1 -fflags +genpts
|
input_args: -re -stream_loop -1 -fflags +genpts
|
||||||
roles:
|
roles:
|
||||||
- detect
|
- detect
|
||||||
detect:
|
|
||||||
height: 1080
|
|
||||||
width: 1920
|
|
||||||
fps: 5
|
|
||||||
```
|
```
|
||||||
|
|
||||||
These input args tell ffmpeg to read the mp4 file in an infinite loop. You can use any valid ffmpeg input here.
|
These input args tell ffmpeg to read the mp4 file in an infinite loop. You can use any valid ffmpeg input here.
|
||||||
|
@ -22,8 +22,6 @@ cameras:
|
|||||||
- detect
|
- detect
|
||||||
detect:
|
detect:
|
||||||
enabled: False # <---- disable detection until you have a working camera feed
|
enabled: False # <---- disable detection until you have a working camera feed
|
||||||
width: 1280 # <---- update for your camera's resolution
|
|
||||||
height: 720 # <---- update for your camera's resolution
|
|
||||||
```
|
```
|
||||||
|
|
||||||
### Step 2: Start Frigate
|
### Step 2: Start Frigate
|
||||||
@ -105,9 +103,6 @@ cameras:
|
|||||||
- path: rtsp://10.0.10.10:554/rtsp
|
- path: rtsp://10.0.10.10:554/rtsp
|
||||||
roles:
|
roles:
|
||||||
- detect
|
- detect
|
||||||
detect:
|
|
||||||
width: 1280
|
|
||||||
height: 720
|
|
||||||
motion:
|
motion:
|
||||||
mask:
|
mask:
|
||||||
- 0,461,3,0,1919,0,1919,843,1699,492,1344,458,1346,336,973,317,869,375,866,432
|
- 0,461,3,0,1919,0,1919,843,1699,492,1344,458,1346,336,973,317,869,375,866,432
|
||||||
|
@ -26,6 +26,7 @@ from frigate.util.builtin import (
|
|||||||
deep_merge,
|
deep_merge,
|
||||||
escape_special_characters,
|
escape_special_characters,
|
||||||
get_ffmpeg_arg_list,
|
get_ffmpeg_arg_list,
|
||||||
|
get_video_properties,
|
||||||
load_config_with_no_duplicates,
|
load_config_with_no_duplicates,
|
||||||
)
|
)
|
||||||
from frigate.util.image import create_mask
|
from frigate.util.image import create_mask
|
||||||
@ -42,6 +43,7 @@ FRIGATE_ENV_VARS = {k: v for k, v in os.environ.items() if k.startswith("FRIGATE
|
|||||||
DEFAULT_TRACKED_OBJECTS = ["person"]
|
DEFAULT_TRACKED_OBJECTS = ["person"]
|
||||||
DEFAULT_LISTEN_AUDIO = ["bark", "speech", "yell", "scream"]
|
DEFAULT_LISTEN_AUDIO = ["bark", "speech", "yell", "scream"]
|
||||||
DEFAULT_DETECTORS = {"cpu": {"type": "cpu"}}
|
DEFAULT_DETECTORS = {"cpu": {"type": "cpu"}}
|
||||||
|
DEFAULT_DETECT_DIMENSIONS = {"width": 1280, "height": 720}
|
||||||
|
|
||||||
|
|
||||||
class FrigateBaseModel(BaseModel):
|
class FrigateBaseModel(BaseModel):
|
||||||
@ -284,8 +286,8 @@ class StationaryConfig(FrigateBaseModel):
|
|||||||
|
|
||||||
|
|
||||||
class DetectConfig(FrigateBaseModel):
|
class DetectConfig(FrigateBaseModel):
|
||||||
height: int = Field(default=720, title="Height of the stream for the detect role.")
|
height: Optional[int] = Field(title="Height of the stream for the detect role.")
|
||||||
width: int = Field(default=1280, title="Width of the stream for the detect role.")
|
width: Optional[int] = Field(title="Width of the stream for the detect role.")
|
||||||
fps: int = Field(
|
fps: int = Field(
|
||||||
default=5, title="Number of frames per second to process through detection."
|
default=5, title="Number of frames per second to process through detection."
|
||||||
)
|
)
|
||||||
@ -1020,6 +1022,32 @@ 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:
|
||||||
|
stream_info = {"width": 0, "height": 0}
|
||||||
|
try:
|
||||||
|
stream_info = get_video_properties(input.path)
|
||||||
|
except Exception:
|
||||||
|
logger.warn(
|
||||||
|
f"Error detecting stream resolution automatically for {input.path} Applying default values."
|
||||||
|
)
|
||||||
|
stream_info = {"width": 0, "height": 0}
|
||||||
|
|
||||||
|
camera_config.detect.width = (
|
||||||
|
stream_info["width"]
|
||||||
|
if stream_info.get("width")
|
||||||
|
else DEFAULT_DETECT_DIMENSIONS["width"]
|
||||||
|
)
|
||||||
|
camera_config.detect.height = (
|
||||||
|
stream_info["height"]
|
||||||
|
if stream_info.get("height")
|
||||||
|
else DEFAULT_DETECT_DIMENSIONS["height"]
|
||||||
|
)
|
||||||
|
|
||||||
# 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:
|
||||||
|
Loading…
Reference in New Issue
Block a user