Rotate and Flip Video with FFmpeg Transpose
This article explains how to use the transpose video
filter in FFmpeg to rotate a video clockwise and flip it simultaneously.
You will find the exact command-line syntax and the specific parameters
required to achieve different rotation and flipping combinations
quickly.
To rotate a video 90 degrees clockwise and flip it vertically, you
can use the built-in transpose filter with the value
3 (also known as clock_flip).
Here is the basic command to perform this action:
ffmpeg -i input.mp4 -vf "transpose=3" output.mp4Understanding the Transpose Filter Values
The transpose filter accepts specific numerical values
(0 to 3) to perform pre-defined rotation and flip combinations:
0: Rotate 90 degrees counter-clockwise and flip vertically.1: Rotate 90 degrees clockwise.2: Rotate 90 degrees counter-clockwise.3: Rotate 90 degrees clockwise and flip vertically.
How to Rotate Clockwise and Flip Horizontally
If you want to rotate the video 90 degrees clockwise and flip it
horizontally instead of vertically, you can chain the
transpose filter with the hflip filter:
ffmpeg -i input.mp4 -vf "transpose=1,hflip" output.mp4Optimizing the Command
To speed up the process, you can copy the audio stream without
re-encoding it by using the -c:a copy parameter:
ffmpeg -i input.mp4 -vf "transpose=3" -c:a copy output.mp4