How to Rotate a Video with FFmpeg?

Author: Vita
Publish date
Apr 17, 2024
Rotate Any Video Free
  • How do you rotate a video for free without a watermark?
  • Step 1. Download Download Free HD Video Converter Factory.
  • Step 2. Open Converter and add a video file.
  • Step 3. Rotate or flip the video.
  • Step 4. Choose an output format and export the file.
Quick Navigation
Part 1: Rotate Video with FFmpeg
Part 2: Rotate Video with FFmpeg Alternative
Facebook
Twitter
Pinterest
Linkedin
Reddit

– 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.

Part 1: Guide on How to Rotate a Video in FFmpeg

Before anything else, please install FFmpeg and set up the software perfectly on your computer.

Step 1. Open the FFmpeg command window

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.

Open Command Prompt Window
Open Command Prompt Window

Step 2. Rotate videos in FFmpeg

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

  • Replace "input.mp4" and "output.mp4" based on your actual circumstance.

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

FFmpeg Rotate Video 90 Degrees
FFmpeg Rotate Video 90 Degrees

–– 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

  • "PI" refers to π, and "bilinear=0" can make the video not blurry.

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

FFmpeg Rotate Video 45 Degrees
FFmpeg Rotate Video 45 Degrees

–– 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

FFmpeg Flip Video
FFmpeg Flip Video

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

  • -metadata:s:v rotate="90" will rotate the video 90 degrees counterclockwise. You can rotate clockwise by using -90.
  • -codec copy will not re-encode the video but copy the video stream into the output file.
WonderFox Free HD Video Converter Factory
One-Click to Rotate Any Video!

Free HD Video Converter Factory offers an easy way to rotate and flip videos on Windows. It also allows you to preview the video after you make a tweak. Moreover, trimming, merging, and converting can be done with several clicks. Try this free yet powerful video software now!

Free download Download for Free
Free download Download for Free

Part 2: An Alternative Way to Rotate Videos on PC

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!

Free download Download for Free
Free download Download for Free

How to rotate your video with this FFmpeg alternative tool:

Step 1. Add video files

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.

Add Video File
Add Video File

Step 2. Rotate or flip the video

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.

Rotate Video
Rotate Video

Step 3. Export the rotated file

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.

Export Video
Export Video

Wrap-up

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!

Similar Articles
FFmpeg Merge Audio and Video

FFmpeg Merge Audio and Video

FFmpeg Trim Video

FFmpeg Trim Video

FFmpeg MKV to MP4

FFmpeg Convert MKV to MP4

WonderFox HD Video Converter Factory Pro
Batch Process Video Files | No Quality Loss

Upgrade to Pro to enjoy more features and better video quality!

  • Rotate, flip, cut, crop, merge, and compress videos without losing quality.
  • Batch convert videos to 500+ profiles.
  • Download SD/HD/FHD/4K/8K videos from websites.
  • Record streaming TV, video calls, games, etc.
  • Add audio, subtitles, watermarks, or video effects.
  • Make GIF animations, ringtones, and split-screen videos.
Free download Download for Free
Free download Download for Free
* Explore details on the product page >>
Specialized in multimedia software solutions.
Since 2009

Terms and Conditions | Privacy Policy | License Agreement | Copyright © 2009-2024 WonderFox Soft, Inc.All Rights Reserved

Back to Top