meh / rust-ffmpeg

Safe FFmpeg wrapper.
Do What The F*ck You Want To Public License
462 stars 96 forks source link

stream: Allow to get/set display rotation. #181

Closed projectgus closed 10 months ago

projectgus commented 10 months ago

Wraps the relevant side_data accessors and display.h utility functions for this. The API is a bit weird as things apply to an abstract Stream in libavcodec, couldn't see a better way to factor it.

kornelski commented 10 months ago

Is the matrix useful for anything else? Maybe these methods could take/return the 9-element DisplayMatrix type, which has rotation() and from_rotation() methods?

projectgus commented 10 months ago

@kornelski It's a very reasonable question, thanks! My thinking on this was:

  1. I don't know of another use for it. It's quite conceptually neat that you have this full transformation matrix. However, both ffmpeg and ffprobe seem to support it only as a rotation.[*] I wasn't able to turn up another use for it.
  2. The data format is 16.16 fixed point, so I figure representing it in an ergonomic way for Rust means either pulling in a fixed point crate or doing somewhat hacky format conversions. I wasn't really sure about either of these approaches.

All that said, if you think it may be useful then I am very happy to refactor this to introduce a DisplayMatrix type as described. If so, then I would appreciate any advice on the most appropriate answer for point (2), above. Cheers!

[*] For completeness, I stumbled across it when processing some QuickTime videos taken by iOS, where the rotation of the phone is encoded here.

kornelski commented 10 months ago

Thanks for the explanation

projectgus commented 10 months ago

Thanks for the quick merge!