Ticket #515 (open defect)
Problem in video rotation in FFMPEG for IPhone video
| Reported by: | Gagan | Owned by: | |
|---|---|---|---|
| Priority: | normal | Component: | FFmpeg |
| Version: | git-master | Keywords: | mov |
| Cc: | Blocked By: | ||
| Blocking: | Reproduced by developer: | yes | |
| Analyzed by developer: | no |
Description
I am trying to to compress IPhone recorded .mov file in to .mp4. If i record video in portrait mode in IPhone then after compression output video rotate automatically by 90 degree. I saw there are many patches given by some guys but they are just for extracting orientation information not for rotating output video.
I am working on 0.8.4 version. Please let me know are you planning to fix this issue in coming build version or is there any other way to handle this issue ?
Change History
comment:2 Changed 20 months ago by Gagan
I am not working from command line tool. I integrated ffmpeg libraries in my IPhone project and doing compression through code. Can you tell me how can we rotate video through code ? I apply the fixes or patches given by few users in "mov_read_tkhd" method in mov.c file (see below). But i guess they are to just extract orientation information in auxMatrix, but i want to rotate file by 90 degree.
for (i = 0; i < 3; i++) {
st->auxMatrix[i][0] = display_matrix[i][0] = avio_rb32(pb); 16.16 fixed point
st->auxMatrix[i][1] = display_matrix[i][1] = avio_rb32(pb); 16.16 fixed point
avio_rb32(pb); 2.30 fixed point (not used)
}
comment:3 Changed 11 months ago by cehoyos
- Keywords mov added
- Version changed from 0.8.4 to git-master
comment:4 Changed 6 months ago by cehoyos
- Status changed from new to open
- Component changed from avformat to FFmpeg
- Reproduced by developer set
out.avi is not rotated correctly. ffmpeg should honor the "rotate" metadata set by the mov demuxer and automatically insert the transpose filter.
$ ffmpeg -i sample-in-issue-505.mov -an out.avi
ffmpeg version N-46747-ga1b5c96 Copyright (c) 2000-2012 the FFmpeg developers
built on Nov 15 2012 09:06:47 with gcc 4.7 (SUSE Linux)
configuration:
libavutil 52. 6.100 / 52. 6.100
libavcodec 54. 72.100 / 54. 72.100
libavformat 54. 36.100 / 54. 36.100
libavdevice 54. 3.100 / 54. 3.100
libavfilter 3. 23.100 / 3. 23.100
libswscale 2. 1.102 / 2. 1.102
libswresample 0. 16.100 / 0. 16.100
libpostproc 52. 1.100 / 52. 1.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'sample-in-issue-505.mov':
Metadata:
major_brand : qt
minor_version : 0
compatible_brands: qt
creation_time : 2011-09-25 10:10:07
encoder : 4.3.5
encoder-deu : 4.3.5
date : 2011-09-25T12:09:54+0200
date-deu : 2011-09-25T12:09:54+0200
Duration: 00:00:03.49, start: 0.000000, bitrate: 794 kb/s
Stream #0:0(und): Audio: aac (mp4a / 0x6134706D), 44100 Hz, mono, s16, 63 kb/s
Metadata:
creation_time : 2011-09-25 10:10:07
handler_name : Core Media Data Handler
Stream #0:1(und): Video: h264 (Baseline) (avc1 / 0x31637661), yuv420p, 480x272, 712 kb/s, 30 fps, 30 tbr, 600 tbn, 1200 tbc
Metadata:
rotate : 90
creation_time : 2011-09-25 10:10:07
handler_name : Core Media Data Handler
Output #0, avi, to 'out.avi':
Metadata:
major_brand : qt
minor_version : 0
compatible_brands: qt
date-deu : 2011-09-25T12:09:54+0200
ICRD : 2011-09-25T12:09:54+0200
encoder-deu : 4.3.5
ISFT : Lavf54.36.100
Stream #0:0(und): Video: mpeg4 (FMP4 / 0x34504D46), yuv420p, 480x272, q=2-31, 200 kb/s, 30 tbn, 30 tbc
Metadata:
rotate : 90
creation_time : 2011-09-25 10:10:07
handler_name : Core Media Data Handler
Stream mapping:
Stream #0:1 -> #0:0 (h264 -> mpeg4)
Press [q] to stop, [?] for help
frame= 106 fps=0.0 q=7.4 Lsize= 146kB time=00:00:03.53 bitrate= 338.0kbits/s
video:138kB audio:0kB subtitle:0 global headers:0kB muxing overhead 5.898211%
comment:5 Changed 6 months ago by hendry
I'm suffering from this rotation issue WRT Iphone5 videos I take. They are upside down once I've transcoded them. If I do rotate them (which I should not have to do!), then they appear upside down on Safari.
https://github.com/kaihendry/recordmydesktop2.0/issues/1
http://ffmpeg.org/pipermail/ffmpeg-user/2012-November/011227.html
http://thread.gmane.org/gmane.comp.video.ffmpeg.devel/154159
Here is the original movie from my iphone that exhibits the problem with the very latest ffmpeg: http://r2d2.webconverger.org/2012-11-14/silent-boot.mov
I'm *guessing* there is some rotation metadata like what a JPEG stores which some players don't respect?
comment:6 Changed 6 months ago by DonMoir
The original silent-boot.mov has a metadata rotate value of 180 degrees. It is up to any player or converter to take this into account. This rotation value orients the video to normal viewing. Sadly, some players and converters do not take this into account.
It would even be worse if you manually rotated it and the metadata rotate value was left in place in the result output video. Now it would be upside down in programs that do respect the metadata rotate value.



Please add missing information like command line (as short as possible, using no external libraries) and complete, uncut output to make this a valid ticket.
You can use the file sample-in-issue-505.mov from ticket #505