ffmpegscaleresizeaspect-ratiovideo-processingbucket-doc

FFmpeg Scale Filter: Resize Video and Keep Aspect Ratio

·Javid Jamae·5 min read
FFmpeg Scale Filter: Resize Video and Keep Aspect Ratio

You need to resize a video to 1080p, but the input is 4:3 and the output needs to be 16:9. You use -s 1920x1080 and get a stretched, distorted mess. The fix is FFmpeg's scale filter, and specifically, the -2 trick and force_original_aspect_ratio flag.

This guide covers every common scaling scenario: auto-calculation with -2, forced aspect ratios, letterboxing with pad, and how to do it all through an API instead of wrestling with CLI flags.

Quick Answer: Scale Without Distortion

The fastest way to resize a video while keeping its aspect ratio intact:

ffmpeg -i input.mp4 -vf "scale=-2:1080" output.mp4

The -2 tells FFmpeg to calculate the width automatically based on the input's aspect ratio, rounding to the nearest even number (which video codecs require). Your 4:3 input becomes 1440x1080. Your 16:9 input becomes 1920x1080. No distortion.

What the -2 Value Actually Does

FFmpeg's scale filter takes width and height as arguments: scale=width:height. When you set either dimension to -1 or -2, FFmpeg calculates that dimension from the other one using the original aspect ratio.

The difference between -1 and -2:

  • -1 calculates the value, but it might produce an odd number (e.g., 1441)
  • -2 does the same calculation but rounds to the nearest even number

Odd pixel dimensions cause encoding failures with H.264 and H.265. Always use -2, not -1.

# Scale to 720p height, auto-calculate width
ffmpeg -i input.mp4 -vf "scale=-2:720" output.mp4

# Scale to 1280 width, auto-calculate height
ffmpeg -i input.mp4 -vf "scale=1280:-2" output.mp4

# Scale to 4K height
ffmpeg -i input.mp4 -vf "scale=-2:2160" output.mp4

force_original_aspect_ratio: Fit or Fill

Sometimes you need the output to be exactly 1920x1080, no exceptions. But your input is 4:3. The force_original_aspect_ratio parameter handles this without stretching.

It has two modes:

decrease shrinks the video to fit inside the target dimensions. The video will be smaller than 1920x1080 on one axis.

ffmpeg -i input.mp4 -vf "scale=1920:1080:force_original_aspect_ratio=decrease" output.mp4

A 4:3 input (like 1440x1080) comes out as 1440x1080, fitting inside the 1920x1080 box.

increase enlarges the video to fill the target dimensions. The video will overflow on one axis.

ffmpeg -i input.mp4 -vf "scale=1920:1080:force_original_aspect_ratio=increase" output.mp4

A 4:3 input comes out as 1920x1440, overflowing the height.

Letterboxing with pad

After using force_original_aspect_ratio=decrease, your video fits inside the target box but doesn't fill it. If you need exactly 1920x1080 with black bars (letterboxing), chain the pad filter:

ffmpeg -i input.mp4 -vf "scale=1920:1080:force_original_aspect_ratio=decrease,pad=1920:1080:(ow-iw)/2:(oh-ih)/2:black" output.mp4

This scales the video to fit, then centers it on a 1920x1080 black canvas. The (ow-iw)/2 and (oh-ih)/2 expressions center the video horizontally and vertically.

Want a white background instead? Change :black to :white. Any hex color works too: :0x1a1a2e for a dark blue.

Common Resolution Targets

Quick reference for the most-used output resolutions:

TargetCommand
480p (SD)`scale=-2:480`
720p (HD)`scale=-2:720`
1080p (Full HD)`scale=-2:1080`
1440p (2K)`scale=-2:1440`
2160p (4K)`scale=-2:2160`
YouTube Shorts (9:16)`scale=1080:-2` then `crop=1080:1920`
Instagram Square`scale=1080:1080:force_original_aspect_ratio=decrease,pad=1080:1080:(ow-iw)/2:(oh-ih)/2`

Scale via the FFmpeg Micro API

If you don't want to install FFmpeg or manage a server, you can resize videos through an API call. FFmpeg Micro accepts the same -vf scale filters as the CLI.

Simple preset (set resolution directly):

curl -X POST https://api.ffmpeg-micro.com/v1/transcodes \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "inputs": [{"url": "https://example.com/video.mp4"}],
    "outputFormat": "mp4",
    "preset": {
      "quality": "high",
      "resolution": "1080p"
    }
  }'

Note: The preset resolution maps to fixed dimensions (1920x1080) and uses -s, which can distort non-16:9 inputs.

Aspect-ratio-safe (use the scale filter):

curl -X POST https://api.ffmpeg-micro.com/v1/transcodes \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "inputs": [{"url": "https://example.com/video.mp4"}],
    "outputFormat": "mp4",
    "options": [
      {"option": "-vf", "argument": "scale=-2:1080"}
    ]
  }'

This is the API equivalent of ffmpeg -i input.mp4 -vf "scale=-2:1080" output.mp4. Same scale filter, same aspect ratio preservation. No FFmpeg installation needed.

Common Pitfalls

Odd dimensions crash H.264 encoding. Use -2 instead of -1. Or add trunc(oh*a/2)*2 arithmetic, but -2 is simpler.

Chaining filters requires commas, not pipes. Write scale=-2:1080,pad=1920:1080 with a comma, not scale=-2:1080 | pad=1920:1080.

Upscaling makes things blurry. Scaling a 480p video to 1080p won't add detail. It just makes the same pixels bigger. If you must upscale, use lanczos: scale=-2:1080:flags=lanczos.

Preset resolution doesn't preserve aspect ratio. Both FFmpeg's -s flag and API resolution presets force exact dimensions. Use the scale filter with -2 for safe resizing.

FAQ

Does ffmpeg scale preserve aspect ratio by default?
No. The default scale=width:height stretches the video to fit both dimensions. Use -2 for auto-calculation or force_original_aspect_ratio to prevent distortion.

What's the difference between -s and -vf scale in FFmpeg?
-s 1920x1080 sets exact output dimensions and can distort. -vf "scale=-2:1080" calculates one dimension from the other to keep the aspect ratio. Use scale for aspect-ratio-safe resizing.

How do I scale a video to a specific width in FFmpeg?
Use scale=WIDTH:-2. For example, ffmpeg -i input.mp4 -vf "scale=1280:-2" output.mp4 sets the width to 1280 and auto-calculates the height.

Can I resize video through an API without installing FFmpeg?
Yes. FFmpeg Micro is a cloud API that accepts the same FFmpeg filters. Send a POST to /v1/transcodes with options: [{"option": "-vf", "argument": "scale=-2:1080"}] and get back the resized video. No server setup required.

*Last verified: June 2026. All code examples tested against FFmpeg 7.x and the FFmpeg Micro API.*

About Javid Jamae

Founder & CEO at FFmpeg Micro

Javid is a software engineer, author, and entrepreneur with over 25 years of professional software development experience across enterprise, startup, and consulting environments. He founded FFmpeg Micro to make video processing accessible to developers through a simple, automation-first REST API.

Software EngineeringVideo ProcessingFFmpegCloud ArchitectureAPI DesignAutomation

Ready to process videos at scale?

Start using FFmpeg Micro's simple API today. No infrastructure required.

Get Started Free