Decouple stream options from PyAV options#71247
Conversation
|
Hey there @hunterjm, @allenporter, mind taking a look at this pull request as it has been labeled with an integration ( |
e548e2e to
d83bda6
Compare
| "rtsp_flags": "prefer_tcp", | ||
| "stimeout": "5000000", | ||
| **options, | ||
| "timeout": "5000000", |
There was a problem hiding this comment.
stimeout was deprecated/renamed as of ffmpeg 4.0 and will be removed in ffmpeg 5.0:
FFmpeg/FFmpeg@ff46124
FFmpeg/FFmpeg@6f34f03
davet2001
left a comment
There was a problem hiding this comment.
Overall looks pretty good to me, just some minor questions.
allenporter
left a comment
There was a problem hiding this comment.
Looks great, appreciate this as it will definitely make it more clear how this works for new folks reading the code. 👍🏼
I have a couple minor comments.
|
I believe we have a new best practice for changes like this which would be:
(I don't think there is widespread use of ffmpeg flags or use of stream in custom components, but just in case it can help.) |
|
Marking as draft pending #71245 |
Co-authored-by: Allen Porter <allen.porter@gmail.com>
48e031b to
1b4d648
Compare
Breaking change
create_stream()takes an options dict and passes it straight through to PyAV, which passes it straight into the ffmpeg libraries. This PR adds an intermediate layer through the newSTREAM_OPTIONS_SCHEMAandconvert_stream_options()function to decouple the options used internally in stream from the options used in ffmpeg. This allows us to 1) restrict the options used to a subset we have tested while also sanitizing them if necessary, 2) change the syntax of the stream options, and potentially 3) group some PyAV options together in a single stream option.This PR doesn't break anything in core, as the appropriate changes have been made to generic and ONVIF, but this may break some custom components which implement
Cameraand use thestream_optionsmember to pass in custom PyAV options.Proposed change
Currently
create_stream()takes an options dict which (after having two options added) passes through to theStreamconstructor, which in turn passes the options through the stream worker, eventually ending up in the PyAV av.open() function. These optionsdon't seem to be used in the HA code baseare used in ONVIF and generic, so those uses were changed here, but it's possible that some custom components also use them.This PR removes passing the options through directly, decoupling the camera/stream interface from the PyAV API. (Note that currently only one option is supported, and that option is still effectively passed through as is.) If desired, specific options can be defined and checked against in create_stream and then added to the options dict. For example, #71245 can add a boolean option
{"rewrite_timestamps" : True}instead of having to know about the PyAV option{"use_wallclock_as_timestamps": "1"}Type of change
Additional information
Checklist
black --fast homeassistant tests)If user exposed functionality or configuration variables are added/changed:
If the code communicates with devices, web services, or third-party tools:
Updated and included derived files by running:
python3 -m script.hassfest.requirements_all.txt.Updated by running
python3 -m script.gen_requirements_all..coveragerc.The integration reached or maintains the following Integration Quality Scale:
To help with the load of incoming pull requests: