Need to change a video’s resolution — resize for social media, or shrink for storage — but worried about distorting the aspect ratio? FFmpeg’s scale filter handles this automatically. This article shows you how to resize without stretching, and covers letterboxing and more.


What You Will Learn

  • Basic syntax of the scale filter
  • How to resize while automatically preserving aspect ratio (-1/-2 syntax)
  • How to apply relative size changes using iw/ih variables
  • How to cap output at a maximum resolution
  • How to add letterbox (black bars) with the pad filter
  • How to specify the output pixel format

Tested version: Verified with FFmpeg 6.1 (verified against real FFmpeg) Target OS: Windows / macOS / Linux


Basic Syntax of the scale Filter

ffmpeg -i input.mp4 -vf scale=1280:720 output.mp4
PartDescription
-vfOption to specify a video filter (same as -filter:v)
scale=width:heightOutput width and height in pixels

When both width and height are specified explicitly, the video will be stretched if the aspect ratio differs. In most cases it is recommended to use the aspect ratio preservation options described below.


Automatic Aspect Ratio Preservation

Difference Between -1 and -2

With the scale filter, setting one dimension to -1 or -2 automatically calculates the other dimension to preserve the aspect ratio.

ValueBehavior
-1Calculates automatically to preserve aspect ratio. May result in an odd number.
-2Preserves aspect ratio while rounding to a multiple of 2 (required for H.264 encoding).

Because H.264 errors on odd pixel dimensions, using -2 is recommended.

Fix Width, Auto-Calculate Height

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

Fix Height, Auto-Calculate Width

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

Relative Resizing (iw / ih Variables)

Using iw (input width) and ih (input height), you can resize relative to the original dimensions.

Scale Down to Half Size

ffmpeg -i input.mp4 -vf scale=iw/2:ih/2 output.mp4

Scale Up to 1.5x

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

Halve Width While Preserving Aspect Ratio

ffmpeg -i input.mp4 -vf scale=iw/2:-2 output.mp4

The iw/ih variables are handy for writing generic scripts without needing to know the original resolution.


Capping Maximum Resolution

Useful when you want to constrain output to no larger than a certain size — for example, limiting 4K source to a maximum of Full HD (1920px). Use the min() function to pick the smaller of the input resolution or the upper limit.

ffmpeg -i input.mp4 -vf "scale='min(1920,iw)':-2" output.mp4

This command keeps the width as-is if it is under 1920, or scales it down to 1920 if it is 1920 or wider. The height is auto-calculated with -2 to preserve the aspect ratio.

Wrap filters that contain expressions in quotes to protect shell special characters (', ,).


Adding Letterbox with the pad Filter

To fit a video of a different aspect ratio into a fixed frame (e.g., output a 16:9 video at 1920×1080 with black bars), combine scale and pad.

ffmpeg -i input.mp4 -vf "scale=1920:1080:force_original_aspect_ratio=decrease,pad=1920:1080:(ow-iw)/2:(oh-ih)/2" output.mp4
PartDescription
scale=1920:1080:force_original_aspect_ratio=decreaseScale down to fit within 1920×1080 while preserving aspect ratio
pad=1920:1080:(ow-iw)/2:(oh-ih)/2Pad to 1920×1080 with center alignment

The default padding color is black. To change it, specify pad=...:color=white or another color.


Specifying the Output Pixel Format

When encoding to H.264, explicitly specifying yuv420p improves compatibility with a wide range of players.

ffmpeg -i input.mp4 -vf scale=1280:-2 -pix_fmt yuv420p output.mp4

You can also add a format filter as part of a chain:

ffmpeg -i input.mp4 -vf "scale=1280:-2,format=yuv420p" output.mp4

Quick Reference Commands

ffmpeg -i input.mp4 -vf scale=1920:1080 output.mp4
ffmpeg -i input.mp4 -vf scale=1280:-2 output.mp4
ffmpeg -i input.mp4 -vf scale=-2:720 output.mp4
ffmpeg -i input.mp4 -vf scale=iw/2:ih/2 output.mp4

Measured Example

This example scales a 1080p/30fps, 2-minute H.264 video down to 720p:

ffmpeg -i input.mp4 \
  -vf "scale=1280:-2,format=yuv420p" \
  -c:v libx264 -crf 23 -preset medium -c:a copy \
  output_720p.mp4

Downscaling reduces the number of pixels, so at the same CRF the output is often smaller than the input. Going from 1080p to 720p can reduce size by roughly 30–60% depending on the source. Processing time depends on both scaling and re-encoding; on a typical 8-core desktop, it may be around real time to 2x real time. Results vary by environment.


Frequently Asked Questions

height not divisible by 2 Error

Occurs when using -1 results in an odd pixel count. Change to -2.

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

Image Looks Blurry After Upscaling

The default scaling behavior can look slightly soft when upscaling, depending on the source. To improve quality, try adding -sws_flags lanczos.

ffmpeg -i input.mp4 -vf scale=3840:-2 -sws_flags lanczos output.mp4


Tested with: ffmpeg 6.1.1 / Ubuntu 24.04 (検証スクリプトで実行確認) Primary sources: ffmpeg.org/ffmpeg-filters.html / ffmpeg.org/ffmpeg.html / trac.ffmpeg.org/wiki/Scaling