– Can FFmpeg rotate video?
– Absolutely YES!
FFmpeg is a complete solution to edit, convert, record, and stream audio and video files. It is a free and open-source command line toolbox available on Windows, Mac, and Linux. There are three ways to rotate a video with FFmpeg:
1. Use the transpose filter to rotate the input video 90°.
2. Use the rotate filter to rotate the input video by an arbitrary angle.
3. Use the hflip and vflip filters to flip the input video.
Next, I will show you how to rotate videos via different FFmpeg filters. Just keep reading to learn the details.
Before anything else, please install FFmpeg and set up the software perfectly on your computer.
On Windows, navigate to the directory path of the video you want to rotate and type cmd in the address bar. Then, press the Enter key to open the command prompt window.
On Mac or Linux, open Terminal and press the Return key to run the command you input.
Now, input a command to let FFmpeg rotate your video. As mentioned above, you can use three different FFmpeg filters to rotate the input video. Here is how to use them in the command:
–– Via the transpose filter
transpose can help you rotate a video 90 degrees clockwise or anti-clockwise and flip a video horizontally or vertically. This filter accepts values from 0 to 3. What do the values present?
0 = 90° counterclockwise and vertical flip
1 = 90° clockwise
2 = 90° counterclockwise
3 = 90° clockwise and vertical flip
For instance, you can run this command to rotate a video 90 degrees clockwise ↻:
ffmpeg -i input.mp4 -vf "transpose=1" output.mp4
You can also combine multiple transpose filters to change the orientation of the video, such as flipping by rotating 90° twice:
ffmpeg -i input.mp4 -vf " transpose=1, transpose=1" output.mp4
–– Via the rotate filter
rotate offers more flexibility and allows you to rotate a video to any precise angles expressed in radians.
For example, rotate a video 180° (by π/1 radians) with this command:
ffmpeg -i input.mp4 -vf "rotate=PI:bilinear=0" output.mp4
Alternatively, you can use degrees instead of radians. E.g. Rotate a video 45°:
ffmpeg -i input.mp4 -vf "rotate=45*(PI/180)" output.mp4
–– Via the hflip and vflip filters
hflip flips a video horizontally while vflip flips the video vertically.
This command will flip your video horizontally:
ffmpeg -i input.mp4 -vf "hflip" output.mp4
Of course, you can combine the two filters to rotate it horizontally and vertically:
ffmpeg -i input.mp4 -vf "hflip, vflip" output.mp4
Pro-tips:
To let FFmpeg rotate video without re-encoding, input this command in the prompt window and press Enter/Return to run it:
ffmpeg -i input.mp4 -metadata:s:v rotate="90" -codec copy output.mp4
Since the FFmpeg command line is complicated and users often make mistakes when typing the command, I recommend you use easy video-rotating tools that require only a few mouse clicks. For example, you can choose WonderFox Free HD Video Converter Factory for its intuitive UI, straightforward process, and high effectiveness. With it, you can rotate any video and export it in high quality.
Get the software nowGet the software now for completely free!
How to rotate your video with this FFmpeg alternative tool:
Install and launch Free HD Video Converter Factory on your desktop. Then, click Converter > + Add Files to import the video you want to rotate. Drag-and-drop is also supported.
Click the rotate ⟲ icon below the source video to bring a new window. You can click the play button to preview/pause the video.
Next, select a rotating method (90° clockwise, 90° anti-clockwise, horizontal flip, or vertical flip) and adjust the video orientation as desired.
Once done, press OK to save your change.
Tap the format image on the upper right side of the interface and choose an output format (e.g., MP4) from the Video tab. Then, click the ▼ button at the bottom to select a destination file path.
Finally, click Run to export the final video files.
This article illustrates how to rotate a video using FFmpeg with different rotation filters. As you can see, the ffmpeg command lines are complex and not friendly to novices. You can take a try or directly switch to the simple alternate method.
Anyway, I hope this post is helpful to you. Thanks for reading!
Terms and Conditions | Privacy Policy | License Agreement | Copyright © 2009-2024 WonderFox Soft, Inc.All Rights Reserved