How to Rotate Video 90 Degrees Counterclockwise in FFmpeg
Rotating a video is a common editing task that can be easily
accomplished using FFmpeg’s powerful command-line interface. This
article explains how to use the FFmpeg transpose filter to
rotate any video 90 degrees counterclockwise (to the left). You will
learn the exact command to run, how the filter parameters work, and how
to preserve your audio stream during the rotation process.
To rotate a video 90 degrees counterclockwise, you need to use the
video filter flag (-vf) along with the
transpose filter set to a value of 2.
Here is the standard command to perform this rotation:
ffmpeg -i input.mp4 -vf "transpose=2" output.mp4Understanding the Command Parameters
-i input.mp4: Specifies the path to your source video file.-vf "transpose=2": Applies the video filter. Thetransposefilter accepts specific numerical values to dictate the rotation direction:0= 90 degrees counterclockwise and vertical flip1= 90 degrees clockwise2= 90 degrees counterclockwise3= 90 degrees clockwise and vertical flip
output.mp4: The name of the newly rotated output file.
Optimizing the Process
Applying a video filter like transpose requires FFmpeg
to decode and re-encode the video stream, which can take some time
depending on your system’s hardware. However, you can speed up the
process by copying the audio track directly without re-encoding it.
To copy the audio stream without changes, add the
-c:a copy parameter to your command:
ffmpeg -i input.mp4 -vf "transpose=2" -c:a copy output.mp4Using this optimized command ensures that your video is rotated exactly 90 degrees counterclockwise while keeping the original audio quality intact and reducing the overall processing time.