I have a video that was rotated 180° when recorded. Is it possible to correct this with FFmpeg?
Some videos, such as from iPhones, are not physically flipped, but contain video stream displaymatrix side data or rotate metadata. Some players ignore these metadata and some do not. Refer to
You need a build that includes commit 1630224, from 2 May 2015, to be able to use the autorotation feature.
To disable this behavior use the
If the input contains no metadata or if your
Media players that use ffmpeg as a decoding backend can also utilize all of its filters. See this screenshot with "Offset & flip" filter.
Alternatively, if you want to re-encode your video, check out Rotating videos with FFmpeg on Stackoverflow.
Following is a bash script which will output the files with the directory structure under "fixedFiles". It transforms and rotates iOS videos and transcodes AVIs. The script relies on having installed both exiftool and ffmpeg.
FFMPEG recently changed the default behavior to auto rotate input video sources with "rotate" meta data.
So a new solution to this problem would be to update FFMPEG to 2.7 or the git master branch.
However: If you have already implemented one of these solutions and update this is bad news. FFMPEG will rotate your video before your filters will rotate again, causing the original problem to reappear. If you don't want to upgrade to 2.7 but want to ensure you're future-proof there's an option to turn off autorotation with
This will work in both old releases and 2.7, but for older versions you might still have to update to the latest "patch" version (see semver to learn what patch is) for this to work.
Here are the steps:
Choose the file settings you want to export as and click “Ok”, to kick off the export.
When the export operation is complete, you’ll find your new file where ever you chose to save it with the correct orientation!
This whole fix took me less than 5 minutes to complete, but depending on the length of the video, it could take much longer (or shorter, again, it varies).