Handbrake: Orientation flags are discarded on encode

Created on 2 Dec 2016  路  3Comments  路  Source: HandBrake/HandBrake

Please describe the problem or feature request in detail:

When encoding video files with an orientation flag (e.g. from iOS) the flag gets discarded and the resulting video will be erroneously rotated.

What are the steps to reproduce this problem:

  1. Take a video with a cell phone, if it is an iPhone, make sure the volume buttons is on top.
  2. Encode the result in Handbrake.

What version of HandBrake you are running:

Version 20161201172113-8a9f21c-master (2016120201)

What operating system and version and you running (e.g. OSX 10.11, Windows 7, Ubuntu 14):

MacOS 10.11.6 (15G1108)

Was there any error message or error dialog, if so please detail or provide screenshots:

None

Please provide the full activity log for the encode or scan attempt. You may attach the log as a file, post a pastebin URL to the log, or place the log inline below:

See attached documents.

Encode Log.txt
exif_post_encode.txt
exif_pre_encode.txt

Enhancement

Most helpful comment

Implemented in #988

All 3 comments

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

Was this page helpful?
0 / 5 - 0 ratings

Related issues

alanorth picture alanorth  路  6Comments

miopad picture miopad  路  6Comments

a7dfj8aerj picture a7dfj8aerj  路  3Comments

Vuurvlieg picture Vuurvlieg  路  5Comments

AlexPasternak picture AlexPasternak  路  5Comments