Add orientation transforms to stream#77439
Conversation
|
Hey there @hunterjm, @allenporter, mind taking a look at this pull request as it has been labeled with an integration ( |
|
It might be preferable to expose/store this option similar to how keepalive is exposed. That way the values can be updated more easily and on the fly, and we also don't have to plumb it through an option on every integration that uses stream. |
|
Added a frontend PR to use this feature. |
|
Not directly related to this PR, but maybe |
I wasn't familiar with the entity registry options but had a look...doesn't that require the camera entities to all have unique IDs? |
|
@emontnemery Since many cameras still don't use config flows, switching to the entity registry doesn't seem like an option. |
allenporter
left a comment
There was a problem hiding this comment.
This is really cool. A few comments below...
Add comments to transform functions Modify operations in 5 and 7 for consistency
Cleanup changes to camera from #77439
|
We should move these settings (both preload and orientation) to the entity registry, as we now have |
|
I don't quite follow. This PR already puts the new orientation options in the entity registry. |
|
OK, sorry then. Then I would suggest to use the normal api's to update the entity registry instead of |
Proposed change
As stream is fmp4/mp4 based, we can apply affine transformations without transcoding by simply modifying the transformation matrix in the mp4 metadata.
The still images generated by stream have always involved decoding a keyframe and reencoding it to jpeg. The additional work of applying a transformation is minimal as it only involves adding a simple numpy operation to the pipeline.
This PR updates stream to change the orientation of video and the generated still images using the 8 EXIF orientations as guidelines. Note that for video, the application of these transforms is player dependent and may only work in browser for now. Also, orientations 5 and 7 do not appear to work properly for video.
This PR also adds an
orientationfield toStreamSettingsand exposes this as a property inStream.In
Camera, anorientationproperty is added toCameraEntityPreferencesand this is exposed to the frontend via thecamera/update_prefswebsocket endpoint. This is essentially howpreload_streamis currently stored/handled.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: