GumletGumlet logo
Pricing
Login
Book a Demo
Signup

Video Editing

4 min read

How to Scale and Resize a Video Using FFmpeg?

Learn how to efficiently scale and resize videos using FFmpeg. This guide provides step-by-step instructions and examples to help you adjust video dimensions while maintaining quality.

Resize a Video Using FFmpeg

Yash Patadia 

Updated on Aug 06, 2024
How to Scale and Resize a Video Using FFmpeg?

Share this Article

FFmpeg is a very useful tool for video processing tasks like scaling and resizing videos. It offers powerful features that can handle these actions efficiently. In this article, you will learn about some of the most frequently used methods and techniques related to scaling and resizing videos through FFmpeg. Additionally, we will explore ways to resize video without quality loss in detail. Let's dive in.

How to Scale and Resize a Video Using FFmpeg?

To start, you need to have FFmpeg installed on your system. If you don't have it installed, you can download it from the official FFmpeg website and follow the installation instructions for your operating system.

For scaling video with FFmpeg, you apply the -vf scale filter, which means "video filter." This filter assists in specifying the width and height that you want for your resulting video.

Code Syntax with Example

To resize a video to a specific resolution, such as 1280x720 pixels, use the following FFmpeg command:

ffmpeg -i input.mp4 -vf scale=1280:720 output.mp4

In this command:

  • -i input.mp4 specifies the input video file.
  • -vf scale=1280:720 applies the scaling filter to resize the video to 1280 pixels in width and 720 pixels in height.
  • output.mp4 is the name of the resized output video file.

This command will make the input video have a resolution of 1280x720 pixels, using FFmpeg to resize its video resolution to 720p. This is a handy method for converting videos into standard resolutions such as 720p, 1080p or your own desired size.

This scale filter helps FFmpeg scale more straightforwardly and simply, letting you adjust the size of your videos as needed. It also ensures that your videos can be used on various platforms and devices.

How to Resize a Video and Keep Aspect Ratio Using FFmpeg?

Maintaining the aspect ratio is crucial to avoid stretching or squashing the video. To ensure the original aspect ratio is preserved, you can use FFmpeg's -vf scale filter with a dynamic scaling approach.

Code Syntax with Example

To resize a video to half its original width and height while maintaining the aspect ratio, use the following FFmpeg command:

ffmpeg -i input.mp4 -vf "scale=iw*0.5:ih*0.5" output.mp4

In this command:

  • iw and ih represent the input video’s width and height.
  • iw*0.5:ih*0.5 scales the width and height to 50% of their original values.

This method ensures that the video is resized without losing its original aspect ratio, making it ideal for various playback devices and screen sizes.

How to Crop a Video Using FFmpeg?

Cropping a video involves selecting a specific rectangular region from the original video. This is useful for removing unwanted parts or focusing on a particular section of the video.

Code Syntax with Example

To crop a video to a 640x480 rectangle starting at position (100, 100) from the top-left corner, use the following FFmpeg command:

ffmpeg -i input.mp4 -vf "crop=640:480:100:100" output.mp4

In this command:

  • crop=640:480:100:100 defines the width, height, and top-left corner coordinates of the crop rectangle.

This command allows you to precisely control which part of the video to keep, making it a powerful tool for video editing and customization.

How to Resize a Video with Black Bars Using FFmpeg?

Sometimes, you may want to resize a video but keep the original aspect ratio by adding black bars (letterboxing or pillarboxing). This ensures that the video fits within a specific resolution without distortion.

Code Syntax with Example

To scale a video to 1280x720 and add black bars to preserve the aspect ratio, use the following FFmpeg command:

ffmpeg -i input.mp4 -vf "scale=1280:720, pad=1280:720:(ow-iw)/2:(oh-ih)/2" output.mp4

In this command:

  • scale=1280:720 resizes the video to 1280x720 pixels.
  • pad=1280:720:(ow-iw)/2:(oh-ih)/2 adds black bars to the top/bottom or sides to maintain the original aspect ratio.

This method ensures that the video fits perfectly within the specified resolution, making it suitable for various display formats.

Conclusion

Whether you need to adjust the video size while keeping its aspect ratio intact, extract frames, extract audio, or include black bars to maintain original proportions, FFmpeg provides clear and strong instructions for achieving these jobs. By following these steps and examples, you can effectively manage video scaling, resizing, and cropping with FFmpeg, ensuring high-quality results tailored to your specific needs.

FAQs

How do I convert MP4 1080p to 720p in FFmpeg?

To resize a 1080p video to 720p, use the following command:

ffmpeg -i input.mp4 -vf scale=1280:720 output.mp4

How do I change the codec in FFmpeg?

To modify the video's codec, apply the -c:v option and then type in your preferred codec. Such as to convert into H.264:

ffmpeg -i input.mp4 -c:v libx264 output.mp4

How to reduce the size of a video without losing quality in FFmpeg?

To reduce the video size while maintaining quality, use a lower bitrate and the -crf (Constant Rate Factor) option:

ffmpeg -i input.mp4 -vcodec libx264 -crf 23 output.mp4

Does FFmpeg reduce quality?

FFmpeg, in its core nature, does not reduce quality. The outcome relies upon settings and options you provide. For maintaining high video quality, utilize higher bitrates, keep aspect ratios intact and use appropriate encoding settings.

Similar readings

image-6830c6392e51fc000f8e5ccd
How to install FFmpeg on Mac?
Posted on Jun 25, 2025
image-67b2338911801a000d575258
How to Create a Video from Images Using FFmpeg?
Posted on Feb 16, 2025
image-677ad4ff63dfe8000c5fac9f
Veo2 vs. Sora AI: Which Is a Better Video Generation Model?
Posted on Jan 05, 2025
Images or videos loading slow?

We compress them so that your users don't need to wait.

Try Gumlet

Images or videos loading slow?We compress them so that your users don't need to wait.  Try Gumlet →

Ready to get started?

Sign up and start optimizing your videos by up to 57% with Gumlet. No credit card required. Reach out to contact sales or to get a custom pricing estimate that fits your needs.

Start now Contact sales →
Optimizing videos is hard, but our pricing is not
Simple per-minute pricing with no hidden fees.
Pricing details →
Effortlessly integrate Gumlet into your existing stack
Upload with API and set webhooks for output in minutes.
Integragtion guide →

Footer

Gumlet Company logo
USA

Gumlet LLC
8 The Green, Dover, DE 19901

Singapore

Gumlet Pte Ltd
20A, Tanjong Pagar Road, Singapore (088 443)

Gumlet aicp logoGumlet soc2 logoGumlet iso logo
PRODUCT
  • Video Overview
  • Video Analytics
  • DRM Video Protection
  • Video CMS
  • Video Protection
  • Video Player Customization
  • Video Streaming
  • Video Transcoding
  • Video DRM
  • Online Video Hosting
  • Image Optimization
  • No-code Integration
  • Wordpress
  • Vimeo Alternative
  • Cloudinary Alternative
  • Imgix Alternative
  • Wistia Alternative
RESOURCES
  • Blog
  • Learn
  • Glossary
  • Tools
  • Startup Credits
  • Why Gumlet
  • Webinars
  • Documentation
  • Howdrm.works
SUPPORT
  • Product Updates
  • Feedback
  • Community
  • Become an Affiliate
  • Contact Us
  • Service Status
COMPANY
  • Pricing
  • About Us
  • Customers
  • Careers
  • Press Kit

© 2025 Gumlet Pte. Ltd.

Privacy Policy

Terms of Service