Use FFmpeg to rotate the video based on its <rotate> metadata? Why does Android put the wrong metadata?

StackOverflow https://stackoverflow.com/questions/23158281

Question

I have a website where the user uploads a video.
For my website i have also an Android application.
The website creates a thumbnail of each uploaded video (from browser or Android).

The problem is that for normal videos it's all OK, but for android my videos are rotated by 90°.

I think that Android has a bug, because when I see with FFmpeg the video's metadata, for a normal recorded video I got a rotate=90 value, and for a 90° rotated video, I don't have anything in the metadata (and the thumbnail is correct).

Why?

This is an image of a normal recorded video (with the phone in portrait mode).

FFmpeg showing the rotate metadata in a normal recorded video

Anyway, I have the metadata in the video, can I create its thumbnail based on its metadata's rotate value without extracting the metadata and then use ffmpeg to rotate the video on this value?

Thank you in advance.

Was it helpful?

Solution

On android, holding your phone in portrait is considered to be 90 degrees. This the convention that android is using:

landscape: 0 portrait: 90 reverse landscape: 180 reverse portrait: 270

I know this doesn't make sense for phones but it does for tablets and there is realy no difference between tablets and phones on android.

So the metadata in the file are correct. The actual problem is that your browser ignores them. See me question here

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top