How to rotate a video in Linux using FFmpeg

This tutorial will show you step by step how to rotate a video clockwise and counter-clockwise and flip a video vertically and horizontally in Linux using FFmpeg.

FFmpeg is a free and open-source project consisting of a vast software suite of libraries and programs for decoding, encoding, transcoding, muxing, demuxing, streaming, filter and play almost any video, audio, and other multimedia files and streams.

FFmpeg is easy to install because it's available in the default repositories and software centers of many popular Linux distributions such as Arch, Debian, Ubuntu, Linux Mint, Manjaro, MX Linux, Fedora, and many other Linux distro's.

How to rotate a video in Linux using FFmpeg

Open a terminal window in the same folder as the video and use one of the following commands.


The following command will rotate a video by 90 degrees counter-clockwise and flip vertically:

ffmpeg -i input-video.mp4 -vf "transpose=0" output-video.mp4

Note: Don't forget to replace input-video.mp4 and output-video.mp4 with the filename of your video.

The following command will rotate a video by 90 degrees clockwise:

ffmpeg -i input-video.mp4 -vf "transpose=1" output-video.mp4

The following command will rotate a video by 90 degrees counter-clockwise:

ffmpeg -i input-video.mp4 -vf "transpose=2" output-video.mp4

The following command will rotate a video by 90 degrees clockwise and flip vertically:

ffmpeg -i input-video.mp4 -vf "transpose=3" output-video.mp4

The following command will rotate a video by 180 degrees clockwise:

ffmpeg -i input-video.mp4 -vf "transpose=2,transpose=2" output-video.mp4

Maybe you're also interested in:

How to convert a video

How to extract audio from a video

How to remove sound from a video


References:

https://www.ffmpeg.org/about.html

https://ffmpeg.org/ffmpeg-filters.html

https://en.wikipedia.org/wiki/FFmpeg

https://www.ostechnix.com/how-to-rotate-videos-using-ffmpeg-from-commandline/