When I convert .mov files from iPhone 4 and .3gp from Android with FFMPEG. I need to rotate the video 90 degress, but iPhone 4s needs 180 degress...
Is there any way to fix this?
When I convert .mov files from iPhone 4 and .3gp from Android with FFMPEG. I need to rotate the video 90 degress, but iPhone 4s needs 180 degress...
Is there any way to fix this?
I don't recall how Android handles this, but iPhones record orientation information in the mov file metadata. Depending on how the camera is held while recording, videos could need 0, 90, 180, or even 270 rotation to play upright after conversion. As yet, I don't know of any additions to ffmpeg to parse this metadata, so you have to do it manually using ffprobe -show_streams
or something similar, and then set the rotation appropriately.
Update: as kibitzer points out ffmpeg does now detect that the video is rotated, but does not yet provide an automatic rotation fix. Instead, you'll still have to parse out the rotation information and use a combination of the transpose
, vflip
, and hflip
video filters to correctly rotate the video.
Newer ffmpeg returns a rotate: metadata header (when you run ffmpeg -i
), which specifies an angle that the video was rotated, so you don't have to parse the rotation matrix yourself and can just rotate the video by using ffmpeg's filters.
For example, if ffmpeg output rotate: 90 then you would run something like:
ffmpeg -y -i rotated_vid.mov -vf "transpose=1" correct_video.avi
I use a program called mediainfo who show the orientation angle and put in the ffmpeg options:
-vf %ROTATE%
ffmpeg in 95% of the cases understand the orientation but there are some cases, in some hardwares...