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

I have a website where a user uploads a video.
For my site, I have an Android app.
The website creates a thumbnail of each downloaded video (from a browser or Android).

The problem is that for normal videos, everything is fine, but for android, my videos rotate 90 Β°.

I think Android has an error, because when I see video metadata with FFmpeg, I got rotate = 90 for a normal recorded video, and I don’t have anything in the metadata for a 90 Β° rotated video (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 metadata in the video, can I create a thumbnail based on its metadata, rotate the value without extracting the metadata, and then use ffmpeg to rotate the video by that value?

Thanks in advance.

+2
source share
1 answer

On an Android phone, holding the phone in a portrait counts 90 degrees. This is the convention that android uses:

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

I know that this does not make sense for phones, but this applies to tablets, and there is no real difference between tablets and Android phones.

So, the metadata in the file is correct. The actual problem is that your browser ignores them. See Question here

+1
source

All Articles