When encoding video files with an orientation flag (e.g. from iOS) the flag gets discarded and the resulting video will be erroneously rotated.
Version 20161201172113-8a9f21c-master (2016120201)
MacOS 10.11.6 (15G1108)
None
See attached documents.
Yup, the version of libav we use does not support the orientation flag I'm afraid.
I have been learning on the past weeks the meaning of rotation. I suppose that something about displaymatrix is what would allow this feature.
Adding some further information (not very visible in the EXIF output, given that the matrix is identity in both cases which seems wrong). Using ffprobe -show_streams ORIGINAL_VIDEO.MP4 yields those interesting lines:
[STREAM]
...
TAG:rotate=90
...
[SIDE_DATA]
side_data_type=Display Matrix
side_data_size=36
displaymatrix=
00000000: 0 65536 0
00000001: -65536 0 0
00000002: 0 0 1073741824
rotation=-90
[/SIDE_DATA]
[/STREAM]
However, the converted video does not have any SIDE_DATA nor the TAG:rotate. Which is why the converted video "loses" the rotation.
In the one hand, I was feeling like the TAG:rotate could be added somewhere in muxavformat.c:avformatInit. It _is_ metadata, isn't it?
On the other hand, the displaymatrix stuff seems to be supported in the libavformat. I was looking into AVFrame documentation and noticed some AV_FRAME_DATA_DISPLAYMATRIX which is this rotation matrix.
Maybe HandBrake could passthrough both the displaymatrix and rotate tags? I feel bad for not working on a patch, but it surpasses my coding skills and field :( Just looking forward for this feature and wanting to help for it.
Implemented in #988
Most helpful comment
Implemented in #988