Resize a video with FFmpeg
The scale filter does the work. The examples below downscale 1080p to 720p, halve a video, fit it into a square with padding and fill a 9:16 frame by cropping, each checked with ffprobe.
Verified with FFmpeg 9.0.1 on 26 August 2026. Search intent: ffmpeg resize video.
ffmpeg -i input.mp4 -vf "scale=1280:-2" -c:v libx264 -crf 23 -preset medium -c:a copy output.mp4Scales the width to 1280 px and lets FFmpeg compute an even height that keeps the aspect ratio: the 1920x1080 test file became 1280x720. The video is re-encoded at CRF 23, the audio is copied. Size went from 9.9 MB to 2.5 MB.
Flags, explained
- -vf "scale=1280:-2"
- Video filter: scale to width 1280, height computed to keep the aspect ratio and rounded to an even number.
- -2
- Auto-compute this dimension, keeping it divisible by 2. -1 also auto-computes but can yield an odd size, which the H.264 encoder rejects with yuv420p.
- force_original_aspect_ratio=decrease
- Shrink until the whole picture fits inside the target box. Use increase to cover the box (then crop).
- pad=W:H:x:y
- Add borders to reach W x H, placing the picture at x,y. (ow-iw)/2 centres it horizontally.
- crop=W:H
- Keep a W x H window from the centre of the frame.
- -crf 23 -preset medium
- x264 defaults: good quality at a reasonable size. Lower CRF means bigger and better.
- -c:a copy
- Audio is untouched by scaling, so copy it instead of re-encoding.
Variants
Set the height instead of the width
ffmpeg -i input.mp4 -vf "scale=-2:720" -c:v libx264 -crf 23 -preset medium -c:a copy output.mp4Same result on a 16:9 source (1280x720). Use this form when the target height is what you know.
Halve the dimensions
ffmpeg -i input.mp4 -vf "scale=iw/2:-2" -c:v libx264 -crf 23 -preset medium -c:a copy output.mp4iw and ih are the input width and height, so the expression works on any source. 1920x1080 became 960x540.
Fit inside a square with padding (no cropping)
ffmpeg -i input.mp4 -vf "scale=1080:1080:force_original_aspect_ratio=decrease,pad=1080:1080:(ow-iw)/2:(oh-ih)/2" -c:v libx264 -crf 23 -preset medium -c:a copy square.mp4force_original_aspect_ratio=decrease scales the video so it fits inside 1080x1080, then pad fills the rest with black and centres the picture. Output: 1080x1080 with the 16:9 picture letterboxed.
Fill a 9:16 frame by cropping the sides
ffmpeg -i input.mp4 -vf "scale=1080:1920:force_original_aspect_ratio=increase,crop=1080:1920" -c:v libx264 -crf 23 -preset medium -c:a copy vertical.mp4increase scales the video until it covers 1080x1920, then crop cuts the centre. The subject must be in the middle of the frame or it gets cut off. Output: 1080x1920.
Sharper downscale with Lanczos
ffmpeg -i input.mp4 -vf "scale=1280:-2:flags=lanczos" -c:v libx264 -crf 23 -preset medium -c:a copy output.mp4Same 1280x720 output with the Lanczos resampler instead of the default bicubic. Slightly sharper edges, slightly larger file (2.8 MB against 2.5 MB here).
Pitfalls we hit
- scale=640:-1 fails on sources whose aspect ratio gives an odd height. A 1280x714 test clip produced "height not divisible by 2" and no output; scale=640:-2 always works.
- -s 1280x720 forces the exact size and distorts anything that is not 16:9. The scale filter with -2 keeps the aspect ratio.
- Upscaling does not add detail; it only makes the file bigger. Encode at the source size and let the player scale.
- Cropping to 9:16 with crop=1080:1920 keeps the centre of the frame. For interviews and talking heads that is usually right; for wide shots consider padding or a blurred background instead.
How we verified it
Run with FFmpeg 9.0.1 on 26 August 2026 against a 12 s, 1920x1080, 30 fps H.264/AAC file of 9,862,251 bytes. scale=1280:-2 → 1280x720, 2,532,339 bytes; scale=-2:720 → 1280x720; scale=iw/2:-2 → 960x540; square pad → 1080x1080; 9:16 crop → 1080x1920; lanczos → 1280x720, 2,784,789 bytes. scale=640:-1 on a 1280x714 clip failed with an odd height (640x357).
The same edit as a typed operation
resize_video takes a target aspect ratio or size plus a fit mode (cover crops, contain pads) and builds the scale, crop and pad chain itself, with even dimensions guaranteed. Odd sizes and distortion cannot happen.
{
"inputs": [{ "id": "main", "url": "https://example.com/video.mp4" }],
"options": { "aspect_ratio": "9:16", "fit": "cover" }
}FAQ
How do I resize a video without losing quality?
Scaling always re-encodes the video, so choose a low CRF (18 to 20) and a slower preset to keep the loss invisible. The audio can be copied as is.
How do I resize to 1080p, 720p or 480p?
Use scale=-2:1080, scale=-2:720 or scale=-2:480. The width follows the aspect ratio and stays even.
What is the difference between scale, pad and crop?
scale changes the picture size. pad adds borders around it to reach a frame size without distortion. crop removes the outside of the picture to fill a frame. The fit variants above combine them.
Can I change the aspect ratio without cropping or black bars?
Only by distorting the picture, which is rarely wanted. The usual alternatives are padding, cropping, or a blurred copy of the video as background, which is what KinoPipe does for 9:16 by default.
Related commands
- ffmpeg compress videoCompress a video with FFmpegRead
- ffmpeg mov to mp4Convert MOV to MP4 with FFmpegRead
- ffmpeg video to gifConvert a video to GIF with FFmpegRead