Resize Videos With the FFmpeg Scale Filter
Resize video with the FFmpeg scale filter, keep the aspect ratio with -1 and -2, fit inside a box, and pick a scaling algorithm for sharp results.

Resizing is the most common filter job in FFmpeg: a 4K recording that must become 1080p, a clip for a phone that should be 720 pixels tall, a thumbnail at a fixed width. The scale filter does all of it, but three details decide whether the result is right: how you keep the aspect ratio, how you avoid odd sizes that break H.264, and how you fit a video inside a box without stretching it. This post covers each on FFmpeg 7.1, with a command and its effect for every case.
The basic form
ffmpeg -i input.mp4 -vf scale=1280:720 -c:v libx264 -crf 22 -c:a copy output.mp4-vf scale=1280:720 applies the scale filter to the video: width 1280, height 720. The audio is copied untouched. Note that scale=1280:720 forces exactly that size. If the input is a different shape, such as 4:3, the picture stretches. Avoid this unless you want it.
Keep the aspect ratio with -1 and -2
Give one dimension and let FFmpeg compute the other by passing a negative number:
ffmpeg -i input.mp4 -vf scale=1280:-2 -c:v libx264 -crf 22 -c:a copy output.mp4-1 means "calculate this value to preserve the aspect ratio". -2 does the same and also rounds to a multiple of 2. The second form is almost always the one you want for H.264, because yuv420p needs even sizes. With a 1920x1080 input, scale=1280:-2 gives 1280x720. With a 1920x800 input (a wide film frame), it gives 1280x534, since 1280 times 800 over 1920 is 533.33, and FFmpeg rounds to the even number 534.
The same pattern fixes the height:
ffmpeg -i input.mp4 -vf scale=-2:720 -c:v libx264 -crf 22 -c:a copy output.mp4This is the usual way to make "720p" versions of clips with different shapes, since the height is fixed and the width follows.
Use expressions for relative sizes
The filter accepts expressions that use the input size as iw (input width) and ih (input height):
ffmpeg -i input.mp4 -vf "scale=iw/2:ih/2" -c:v libx264 -crf 22 -c:a copy half.mp4This halves both dimensions. If the input has an odd size, the result can be odd too, so for H.264 prefer the rounded form:
ffmpeg -i input.mp4 -vf "scale=trunc(iw/4)*2:trunc(ih/4)*2" -c:v libx264 -crf 22 -c:a copy half.mp4trunc(iw/4)*2 divides by four, drops the fraction, then doubles, which gives half the width rounded down to an even number. Quote the filter string, because the shell treats parentheses and the * character specially.
Fit inside a box without stretching
A common need: make the video fit within 1280x720 whatever its shape, never larger, never distorted. The scale filter has the force_original_aspect_ratio option for this:
ffmpeg -i input.mp4 -vf "scale=1280:720:force_original_aspect_ratio=decrease" -c:v libx264 -crf 22 -c:a copy fit.mp4With decrease, FFmpeg shrinks the picture until it fits inside the box and keeps its shape. A 1080x1920 portrait video becomes 405x720, because the height limit applies first. Use increase to grow it until it covers the box, which is the first half of a crop-to-fill job. The result may not be exactly 1280x720, so if you need an exact frame, follow with pad to add bars, as the crop and pad post in this cluster shows:
ffmpeg -i input.mp4 -vf "scale=1280:720:force_original_aspect_ratio=decrease,pad=1280:720:(ow-iw)/2:(oh-ih)/2" -c:v libx264 -crf 22 -c:a copy boxed.mp4The filters run left to right, separated by a comma. scale fits the picture, and pad centres it on a 1280x720 canvas. ow and oh are the pad filter's output size, and iw and ih are its input size.
The force_divisible_by option, added in FFmpeg 4.3, rounds the result to a multiple you choose, and it works together with force_original_aspect_ratio:
ffmpeg -i input.mp4 -vf "scale=1280:720:force_original_aspect_ratio=decrease:force_divisible_by=2" -c:v libx264 -crf 22 -c:a copy fit.mp4Check the result
Ask ffprobe for the output size:
ffprobe -v error -select_streams v:0 -show_entries stream=width,height -of csv=p=0 fit.mp4405,720That is the portrait example above. For your file the numbers will follow your input. Making this check part of a script catches a size you did not expect before you upload a long batch.
Pick a scaling algorithm
The scale filter's flags option sets the interpolation method. FFmpeg's default for downscaling is bicubic, which is a sound choice. Others:
| Flag | Character | Use it when |
|---|---|---|
bilinear | fast, soft | Speed matters more than sharpness |
bicubic | balanced default | Most downscales |
lanczos | sharper, can ring on edges | Downscaling photos or detailed footage |
neighbor | blocky, exact pixels | Pixel art and screenshots of low-resolution games |
spline | smooth and sharp | An alternative to lanczos |
Set it like this:
ffmpeg -i input.mp4 -vf "scale=1280:-2:flags=lanczos" -c:v libx264 -crf 22 -c:a copy sharp.mp4For a large downscale such as 4K to 720p, lanczos often looks crisper. For pixel art that you enlarge by a whole-number factor, flags=neighbor keeps the pixels square. The FFmpeg scaler documentation lists every flag; those are the ones that matter in practice.
Scale and colour range
When you resize, the scale filter also handles pixel format conversion if it is asked to. If you pass -pix_fmt yuv420p after the filter, FFmpeg inserts conversion automatically. A source in a different colour format, such as yuv444p, is then converted in the same scaler step. You will see the details in the format and scale post at the end of this cluster.
Common mistakes
Using
scale=1280:720on a non-16:9 input and wondering why faces look wide.Using
-1with libx264 and hitting "width not divisible by 2". Use-2.Placing
-vfafter the output filename. Filter options are output options, so they go before the file name.Scaling up. Making a 480p video 1080p adds pixels, not detail. The file grows and looks soft.
Using
-c:v copywith-vf. A filter needs re-encoded video, so copy fails.
We now set -2 by reflex. The cost of -1 was a render queue of forty clips where eleven stopped on an odd height, found only when the job reached them.
Scaling before and after other filters
Filter order matters. Scale before heavy filters when you can, because they then process fewer pixels: a blur or a text overlay on a 720p frame costs less than on a 4K frame. The exception is cropping, which should come first, since it removes pixels you would otherwise scale and then throw away.
ffmpeg -i input.mp4 -vf "crop=1920:800:0:140,scale=1280:-2" -c:v libx264 -crf 22 -c:a copy wide.mp4That removes the black bars from a letterboxed source and then resizes the remaining picture. Reversing the two would resize the bars and then crop in the wrong coordinates.
Two more details are worth knowing. Interlaced sources should be deinterlaced before scaling, because the scaler would blend the fields. And when you change the frame size, the pixel aspect ratio matters: some sources use non-square pixels, and scale leaves the sample aspect ratio tag as it was. Add ,setsar=1 after scale to force square pixels in the output.


