Rotate Video with FFmpeg
How to rotate a video with or without re-encoding using FFmpeg

Sometimes after recording a video using my iPhone, I notice that the orientation is wrong. For example, when I intend to record a vertical video, the final result ends up being horizontal. This happens because the Camera app uses the accelerometer to detect the video orientation at the moment recording starts.
Of course, with the built-in Photos app, I can rotate the video easily. But what if I need to do this on another machine, such as a Raspberry Pi?
That’s where the ultimate video tool comes in: FFmpeg.
Rotate Video without Re-encoding
Here’s the command to rotate a video file without re-encoding it:
ffmpeg -display_rotation 90 -i input.mp4 -codec copy output.mp4
You can use the following options for -display_rotation:
- 0
- 90
- 180
- 270
The display rotation is self-explanatory. Just select the expected rotation based on your current video orientation. Since this method does not require re-encoding, the process is almost instant.
Rotate Video with Re-encoding
If the command above does not work for your case, you can rotate the video by re-encoding it. Use the following command:
ffmpeg -i input.mp4 -vf "transpose=1" output.mp4
Here are the possible values for the transpose parameter and what each one means:
- 0 = 90° counterclockwise and vertical flip (default)
- 1 = 90° clockwise
- 2 = 90° counterclockwise
- 3 = 90° clockwise and vertical flip
Because this method requires re-encoding the video, it may take some time to complete, depending on the video’s length and file size.
Conclusion
As usual, if you have any questions or know a better method, leave a comment below. Thanks for reading, and see you next time!
Cheers!
