Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Add VideoFrame.rotation #1675

Merged
merged 4 commits into from
Dec 9, 2024
Merged

Add VideoFrame.rotation #1675

merged 4 commits into from
Dec 9, 2024

Conversation

lgeiger
Copy link
Contributor

@lgeiger lgeiger commented Dec 5, 2024

This adds a VideoFrame.rotation property which uses av_display_rotation_get to read the rotation value from DISPLAYMATRIX.

This exposes a wrapper around av_display_rotation_get allowing users to read the rotation value from the DISPLAYMATRIX.

Not sure if this is the most usable API but at least this brings back the ability to read display rotation information.

Fixes #1047
Closes #1629

@lgeiger
Copy link
Contributor Author

lgeiger commented Dec 5, 2024

Not sure if this is the most usable API but at least this brings back the ability to read display rotation information.

A more user friendly API would be #1676 but will be a breaking/behaviour change for some users.

@WyattBlue
Copy link
Member

This API seems weird to me
Would frame.rotation be better?

@hmaarrfk
Copy link
Contributor

hmaarrfk commented Dec 8, 2024

This API seems weird to me
Would frame.rotation be better?

My understanding is that the rotation is now part of sidechannel data in MP4 streams.

@lgeiger
Copy link
Contributor Author

lgeiger commented Dec 8, 2024

My understanding is that the rotation is now part of sidechannel data in MP4 streams.

If I understand the FFmpeg documentation correctly, the rotation information is only part of the AVPacket side data (which PyAV doesn't expose yet) or part of the AVFrame side data.

I think frame.rotation would make sense not sure if there is a performance impact to reading the rotation for every frame. Maybe it would be more performant to have packet.rotation instead or in addition? Not sure whether this data can actually change from frame to frame or packet to packet in which case one could do some caching.

@lgeiger lgeiger changed the title Expose av_display_rotation_get Add VideoFrame.rotation Dec 8, 2024
@lgeiger
Copy link
Contributor Author

lgeiger commented Dec 8, 2024

Would frame.rotation be better?

Done in 17b0b96

The mypy failure in tests/test_audioframe.py seems unrelated.

@WyattBlue WyattBlue merged commit 6eaf701 into PyAV-Org:main Dec 9, 2024
8 checks passed
@lgeiger lgeiger deleted the display-rotation branch December 9, 2024 00:57
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Allow access to an affine transform of a particular video tracks display rotation.
3 participants