scale=1280:-2 keeps the shape and an even height: 1280x720 from a 1920x1080 clip. scale=1000:-1 asks libx264 for 1000x563, and it refuses. ReelSDK bills the resize at $0.02 per compute minute, under a quarter of a cent here.
Resize a video with ffmpeg: scale, -2 and fit with pad
Give scale one side and -2 for the other and the aspect ratio holds with an even pixel count. ReelSDK's free video compressor resizes to 720p or 480p in your browser; to fill a 1080x1920 frame, fit the picture and pad the rest.
GuidesUpdated
ffmpeg -i landscape.mp4 -vf scale=1280:-2 -c:a copy 720p.mp4-2 works the height out from the width and rounds it to an even number: 720 for a 1920x1080 clip. -c:a copy leaves the audio alone.
Variations
The other commands you will need
Why -1 can fail
-1keeps the aspect ratio but doesn't round: a 1000-pixel width needs a 562.5-pixel height, ffmpeg made it 563, and libx264 stopped withheight not divisible by 2 (1000x563). Use-2.odd height ffmpeg -i landscape.mp4 -vf scale=1000:-1 odd.mp4Fit a 1080x1920 frame without stretching
force_original_aspect_ratio=decreaseshrinks the picture until it fits the box,padcenters it on a black 1080x1920 canvas, andsetsar=1keeps the pixels square. Without that last filter our file reported an aspect ratio a hair off 9:16.fit and pad ffmpeg -i landscape.mp4 -vf "scale=1080:1920:force_original_aspect_ratio=decrease,\ pad=1080:1920:(ow-iw)/2:(oh-ih)/2,setsar=1" -c:a copy fit.mp4Halve the size with the Lanczos scaler
Expressions work too:
iw/2:ih/2halves both sides, 960x540 here, andflags=lanczospicks the Lanczos scaler instead of the default bicubic.half size ffmpeg -i landscape.mp4 -vf "scale=iw/2:ih/2:flags=lanczos" -c:a copy half.mp4
The flags
The flags in these commands
| Flag | What it does | Used here |
|---|---|---|
scale=1280:-2 | Width 1280, height from the aspect ratio, made divisible by 2 | 1280 wide |
-1 | Keeps the aspect ratio without rounding, so the result can be odd | Odd height |
iw/2:ih/2 | Sizes as expressions of the input width and height | Half size |
force_original_aspect_ratio=decrease | Shrinks the output inside the box to keep the shape; increase grows it to cover the box | Fit |
pad=1080:1920:(ow-iw)/2:(oh-ih)/2 | Centers the picture on a 1080x1920 canvas, black by default | Fit |
setsar=1 | Sets the sample aspect ratio to square pixels | Fit |
flags=lanczos | Chooses the scaling algorithm; bicubic is the default | Half size |
-c:a copy | Copies the audio; only the video is encoded again | Every resize |
Source: ffmpeg filters: scale and pad, checked November 2026.
-1 or -2
Both keep the aspect ratio. With one side at -1, scale works the other side out exactly and rounds it to a whole pixel. With -2, or any -n, ffmpeg "will, however, make sure that the calculated dimension is divisible by n and adjust the value if necessary."
That matters because libx264 encodes the yuv420p format MP4 players expect, which stores colour at half resolution in both directions, and it refuses odd widths and heights. A 1920x1080 clip scaled to 1000 wide needs 562.5 rows; -1 gave 563 and the encoder stopped, -2 would have given 562.
Fit, fill or stretch
Give scale both sizes and it stretches the picture to them. To keep the shape, add force_original_aspect_ratio: decrease fits the picture inside the box, so you pad the gaps, and increase makes it cover the box, so you crop what sticks out. The crop guide covers the crop side.
Fitting a 1920x1080 clip into 1080x1920 gives a 1080-pixel-wide picture with bars above and below. Filling it gives a full frame from the middle of the clip, as in the vertical video guide.
The sample aspect ratio catch
A 1080-pixel width at 16:9 needs 607.5 rows. scale wrote 608 and kept the shape by storing a sample aspect ratio: our fit.mp4 had SAR 1216:1215, so players stretch each pixel by a hair and the file reports a display aspect ratio of 76:135, not 9:16.
Upload checks and editors that read the display aspect ratio see a file that isn't quite vertical. setsar=1 at the end of the chain marks the pixels as square; the same file then reported SAR 1:1 and 9:16, and the size barely moved.
Which scaler
flags picks the algorithm libswscale uses. ffmpeg -h full on our 8.1 build lists bicubic as the default. lanczos is a common choice for downscaling, and neighbor keeps hard pixel edges, which suits pixel art and screen recordings scaled by whole numbers.
Without installing ffmpeg
The same command as one API call
Send the same args to POST /v1/ffmpeg with the clip's URL in inputs. Each job runs ffmpeg 8.1 on a fresh machine at $0.02 per compute minute, billed per second; this resize finished in about 7 seconds and cost under a quarter of a cent.
curl "https://api.reelsdk.com/v1/ffmpeg?wait=60" \
-H "Authorization: Bearer $REELSDK_KEY" \
--json '{
"inputs": {
"landscape.mp4": "https://api.reelsdk.com/f/lib/demo/landscape.mp4"
},
"args": [
"-i", "landscape.mp4", "-vf", "scale=1280:-2", "-c:a", "copy",
"720p.mp4"
],
"outputs": ["720p.mp4"]
}'FAQ
Questions, answered
How do I resize a video and keep the aspect ratio?
Set one side and pass -2 for the other: ffmpeg -i in.mp4 -vf scale=1280:-2 out.mp4. ffmpeg works the missing side out from the aspect ratio and keeps it even, 1280x720 for a 1920x1080 input.
How do I fix height not divisible by 2?
Use -2 instead of -1 for the side ffmpeg calculates, or add force_divisible_by=2 when you use force_original_aspect_ratio. libx264 refuses odd sizes in yuv420p; our scale=1000:-1 asked for 1000x563 and failed.
How do I resize a landscape video to 1080x1920 without stretching?
Fit it with scale=1080:1920:force_original_aspect_ratio=decrease, center it with pad=1080:1920:(ow-iw)/2:(oh-ih)/2 and finish with setsar=1. That keeps the whole picture with bars; cropping instead fills the frame.
Why does my resized video show the wrong aspect ratio?
scale stores a sample aspect ratio when it has to round a side, so the display aspect ratio drifts: our fit came out at 76:135 instead of 9:16. Add setsar=1 at the end of the filter chain.
Can I resize a video without installing ffmpeg?
Yes. Send the same args to POST https://api.reelsdk.com/v1/ffmpeg with the video URL in inputs. It runs ffmpeg 8.1 on a fresh machine per job for $0.02 per compute minute, billed per second, and failed jobs are free.
- Crop a video with ffmpegCut a frame down with crop=w:h:x:y: a centered 9:16 or square crop, a fixed region, and cropdetect to find black bars.
- Vertical video dimensionsThe 9:16 sizes TikTok, Instagram Reels and YouTube Shorts ask for, and the ffmpeg commands that turn any clip into 1080x1920.
- Letterbox and pad a video with ffmpegFit any video into a 9:16, 16:9 or square frame with black or coloured bars, then find and strip bars with cropdetect.
- Blurred background video with ffmpegFit a 16:9 clip into a 9:16 frame over a blurred copy of itself: scale, crop, gblur and overlay in one filter graph.
- Compress a video with ffmpegShrink a video with ffmpeg: CRF 28 in x264 or x265, a smaller frame or a slower preset, with the size and quality each one gets you.
- Resize videoRender 9:16, 1:1, 4:5 and 16:9 copies of one video in a single ffmpeg call, about 2 cents for all 4 from a 30 s clip.
- Vertical video converterTurn a landscape video into a vertical one in your browser, with a blurred background, free and without uploading it.
- height not divisible by 2libx264 refuses a 4:2:0 frame with an odd width or height. Scale with -2, round odd sources to even, or send the args to an API.
Sources, checked November 2026
Ready to build?
Ship video from your app today
Your first $0.50 is free, and one key covers every endpoint.
