New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature: automatic camera resolution configuration #6810
Feature: automatic camera resolution configuration #6810
Conversation
…les with detect in the CameraConfig class in config.py
…aConfig class and add optional parameter to retrieve video duration in get_video_properties function
✅ Deploy Preview for frigate-docs canceled.
|
6e91cb3
to
5ca3035
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe the fps should be set to 5 even if the source stream is higher, this is by design as the default recommended fps for most users. Not all users actually set their cameras to this though.
this PR don't touch fps setting |
Gotcha, my bad |
Also just a reminder once things are decided the configuration/index docs should be updated. In this case the getting started guide should also be updated to remove the recommendation to set the width / height |
And i don’t have idea what’s best to do if several streams are available by URL. To take the first, or the best? |
I'm not familiar with cameras that have multiple streams available on the exact same URL. In that case maybe log a warning that auto detection found multiple resolutions. I think it's safer to pick the lowest quality stream to ensure cpu isn't taxed too much |
0505874
to
4954b26
Compare
4954b26
to
a1aed04
Compare
…nfig to use the defaults" This reverts commit a1aed04.
4793b82
to
2fff932
Compare
Co-authored-by: Nicolas Mowen <nickmowen213@gmail.com>
7f539e5
to
e96150f
Compare
e96150f
to
747006c
Compare
Co-authored-by: Blake Blackshear <blakeb@blakeshome.com>
Earlier versions did autodetect the resolution like this. I remember there being enough issues with the reliability of |
Co-authored-by: Nicolas Mowen <nickmowen213@gmail.com>
aeb3a7b
to
b90eba9
Compare
I can modify |
this is what I am doing for the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think ffprobe should be used to get width / height when cv2 fails. also a couple other docs changes
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I still think the top level "minimal config" should just have the detect config removed.
and regardless, the specific detect config needs to e updated.
frigate/docs/docs/configuration/index.md
Lines 195 to 199 in 7c1568f
detect: | |
# Optional: width of the frame for the input with the detect role (default: shown below) | |
width: 1280 | |
# Optional: height of the frame for the input with the detect role (default: shown below) | |
height: 720 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
but this lines in the 'Full configuration reference' part
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No. on your screenshot lines 3-24. But in this thread we are talking about lines 195-199 (see first message)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Gotcha, but for lines 195-199 they need to be updated because
The defaults are no longer 1280 x 720, the default is now to auto detect with a fallback of 1280x720.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Gotcha, but for lines 195-199 they need to be updated because
I think, here only needs to change the wording of the comment, about autoconfiguration and fallback. And I'm definitely not the best man for that :)
At the moment, this PR does not affect the |
f82776f
to
745a6d1
Compare
frigate/config.py
Outdated
@@ -961,8 +961,16 @@ def runtime_config(self, plus_api: PlusApi = None) -> FrigateConfig: | |||
if "detect" in input.roles: | |||
try: | |||
stream_info = get_video_properties(input.path) | |||
camera_config.detect.width = stream_info["width"] | |||
camera_config.detect.height = stream_info["height"] | |||
camera_config.detect.width = ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let's simplify this code and move this logic outside of the try / except and have the except clause set stream_info to {"width": 0, "height": 0}
that way the values are only set to the config in one place
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you mean that I should manually generate an exception in get_video_properties if one of dimensions is zero?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, this is what I am suggesting
try:
stream_info = get_video_properties(input.path)
except Exception:
stream_info = {"width": 0, "height": 0}
if stream_info["width"] == 0 or stream_info["height"] == 0:
logger.warn(
f"Error detecting stream resolution automatically for {input.path} Applying default values."
)
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"]
)
…pply default values
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"] | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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"] | |
) | |
stream_info = {"width": DEFAULT_DETECT_DIMENSIONS["width"], "height": DEFAULT_DETECT_DIMENSIONS["height"]} | |
try: | |
stream_info = get_video_properties(input.path) | |
except Exception: | |
logger.warn( | |
f"Error detecting stream resolution automatically for {input.path} Applying default values." | |
) | |
camera_config.detect.width = stream_info["width"] | |
camera_config.detect.height = stream_info["height"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you will get width and height values from previous loop iteration, if get_video_properties() fails
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe I'm missing something. I am initializing stream_info
with the defaults before calling get_video_properties
, so I don't see how the previous loop could carry over.
No description provided.