FFmpeg resize and crop video: scale, pad and 9:16
Resize with the scale filter and use -2 for the side you want FFmpeg to work out. On our 1280x720 test file scale=640:-2 gave 640x360. scale=500:-1 failed, because it gave an odd height; scale=500:-2 gave 500x282. This page also covers padding, cropping to 9:16 and the sample and display aspect ratios, all read back with ffprobe.
What to choose
| Goal | Filter | Output on our 1280x720 file |
|---|---|---|
| Smaller, same shape | scale=640:-2 | 640x360 |
| Fixed height, even width | scale=-2:480 | 854x480 |
| Fit into a vertical frame, bars added | scale, pad | 1080x1920 |
| Fill a vertical frame, edges cut | scale, crop | 1080x1920 |
Pad keeps the whole picture and adds bars. Crop fills the frame and cuts the edges. Pick by what you can afford to lose.
Scale and keep the aspect ratio
Give one side and let FFmpeg compute the other. -1 keeps the ratio exactly. -2 keeps it and rounds to an even number, which H.264 with yuv420p needs.
ffmpeg -i a.mp4 -vf scale=640:-2 -c:a copy s640.mp4ffmpeg -i a.mp4 -vf scale=-2:480 -c:a copy s854.mp4ffmpeg -i a.mp4 -vf scale=500:-1 -c:a copy s500.mp4The message was "[libx264 @ ...] height not divisible by 2 (500x281)".
ffmpeg -i a.mp4 -vf scale=500:-2 -c:a copy s500b.mp4Rounding has a side effect we measured. The output of scale=-2:480 had a sample aspect ratio of 1280:1281, and scale=500:-2 had 376:375, not 1:1. Players handle this, but append setsar=1 if you want square pixels. With setsar=1 the 500 wide file measured 1:1.
Pad to a new aspect ratio
force_original_aspect_ratio=decrease scales the picture to fit inside the frame. pad then fills the rest with black and centres the picture. To check where the picture landed, we sampled an 8x8 patch at 3 s: at the centre it averaged RGB (253, 253, 0) (the test pattern) and near the top edge (0, 0, 0) (black bar).
ffmpeg -i a.mp4 -vf "scale=1080:1920:force_original_aspect_ratio=decrease,pad=1080:1920:(ow-iw)/2:(oh-ih)/2:color=black,setsar=1" -c:a copy padded.mp4Without the final setsar=1 the same command gave sample aspect ratio 1216:1215 and display aspect ratio 76:135, which is not the 9:16 we wanted.
Crop to 9:16
crop=ih*9/16:ih takes a full height strip, centred by default. On our 720 pixel high file that expression is 405, but the output was 404 wide.
ffmpeg -i a.mp4 -vf "crop=ih*9/16:ih" -c:a copy crop_only.mp4Scaling that strip to 1080x1920 gave a display aspect ratio of 101:180, not 9:16.
ffmpeg -i a.mp4 -vf "crop=ih*9/16:ih,scale=1080:1920" -c:a copy vertical0.mp4Scaling to the final height first and then cropping to the exact target size gave the exact shape.
ffmpeg -i a.mp4 -vf "scale=-2:1920,crop=1080:1920,setsar=1" -c:a copy vertical.mp4Sample and display aspect ratio
Sample aspect ratio (SAR) is the shape of a pixel. Display aspect ratio (DAR) is the shape of the picture as shown: width over height times SAR. We made a deliberately stretched file: 640x720 with SAR 2:1. ffprobe reported 640,720,2:1,16:9.
ffmpeg -i a.mp4 -vf "scale=640:720,setsar=2/1" -c:a copy sar2.mp4ffmpeg -i sar2.mp4 -vf "scale=iw*sar:ih,setsar=1" -c:a copy sar_fixed.mp4-aspect changes only the flag. With -c copy on our 16:9 file it gave SAR 3:4 and DAR 4:3, and FFmpeg warned "[vost#0:0/copy @ ...] Overriding aspect ratio with stream copy may produce invalid files".
ffmpeg -i a.mp4 -c copy -aspect 4:3 aspect43.mp4Check the result
ffprobe -v error -select_streams v:0 -show_entries stream=width,height,sample_aspect_ratio,display_aspect_ratio -of csv=p=0 sar2.mp4Then play the file. A correct width and height can still hide a wrong sample aspect ratio.
Method and limits
All commands ran on FFmpeg 8.1.2 (a full Windows build) on a Windows 11 laptop, Ryzen 7 7735U, CPU only, on 2026-11-06. We added -y and -threads 4 to every run; they are left out of the commands shown. In quoted FFmpeg messages the hex address after @ changes on every run, so we replaced it with ...
a.mp4 is a synthetic 10 s test file (testsrc2 picture and a sine tone, 1280x720, 30 fps, a keyframe every 2 seconds), made with the command below.
ffmpeg -f lavfi -i testsrc2=duration=10:size=1280x720:rate=30 -f lavfi -i sine=frequency=440:duration=10:sample_rate=48000 -c:v libx264 -pix_fmt yuv420p -g 60 -keyint_min 60 -sc_threshold 0 -c:a aac -shortest a.mp4Limits: one run of each command, so the sizes and times are single measurements and not averages. Times were taken on a laptop that was doing other work. Results depend on the input file and the FFmpeg version, so check yours. We did not test interlaced or rotated files.
Related: FFmpeg for video editors, FFmpeg compress video: CRF and presets, measured with VMAF, FFmpeg overlay text and images: drawtext, logo and picture in picture, FFmpeg trim video: accurate cuts by time and FFmpeg command builder.
Page checked on Nov 4, 2026.