Opened 4 years ago
Closed 4 years ago
#9895 closed defect (invalid)
Autorotate wrong direction for some android mp4 videos
| Reported by: | Taylor Hughes | Owned by: | |
|---|---|---|---|
| Priority: | normal | Component: | undetermined |
| Version: | git-master | Keywords: | rotate |
| Cc: | Blocked By: | ||
| Blocking: | Reproduced by developer: | no | |
| Analyzed by developer: | no |
Description (last modified by )
Summary of the bug: For some mp4 uploads from native android apps (probably using a weird and/or broken encoder), ffmpeg interprets the rotation differently from Chrome/Quicktime and autorotates the video incorrectly, despite the rotation/display matrix appearing correct via ffprobe.
How to reproduce:
Given video in this unusual format (attached) with rotation = 90
ffmpeg -i upsidedown-original.mp4 -y upsidedown-out.mp4
Upside down video results with rotation = 0
ffprobe output for original video:
[STREAM] index=1 codec_name=h264 ... [SIDE_DATA] side_data_type=Display Matrix displaymatrix= 00000000: 0 -65536 0 00000001: 65536 0 0 00000002: 0 0 1073741824 rotation=90 [/SIDE_DATA] [/STREAM]
but ffmpeg -debug log indicates cclock instead of clock rotation for 90deg:
[transpose @ 0x149f0a260] Setting 'dir' to value 'cclock'
resulting output video thus appears 180deg from expectation
Attachments (2)
Change History (8)
by , 4 years ago
| Attachment: | upsidedown-original.mp4 added |
|---|
by , 4 years ago
| Attachment: | ffmpeg-20220829-111005.log added |
|---|
log of encoding this mp4, note the rotation = 90 yet dir = cclock (rather than clock)
comment:1 by , 4 years ago
| Description: | modified (diff) |
|---|
comment:2 by , 4 years ago
| Description: | modified (diff) |
|---|
comment:3 by , 4 years ago
| Description: | modified (diff) |
|---|
comment:4 by , 4 years ago
| Keywords: | rotate added |
|---|---|
| Version: | unspecified → git-master |
Chrome and WMP do what FFmpeg does, vlc and (old) Firefox rotate the video differently.
comment:6 by , 4 years ago
| Resolution: | → invalid |
|---|---|
| Status: | new → closed |
There is a matrix in the track to rotate -90 degrees (counterclockwise), and a matrix in movie header to rotate -180 degrees. The second one is applied after the first one, so it's -270 degrees, which is the same as 90 degrees.
VLC failed to handle the second matrix, FFmpeg does which the specification required.



mp4 from android encoder that is probably somehow invalid