Originally published at ffmpeg-micro.com
You need to resize a video to 1080p, but the input is 4:3 and the output needs to be 16:9. You use -s 1920x1080 and get a stretched, distorted mess. The fix is FFmpeg's scale filter, and specifically, the -2 trick and force_original_aspect_ratio flag.
This guide covers every common scaling scenario: auto-calculation with -2, forced aspect ratios, letterboxing with pad, and how to do it all through an API instead of wrestling with CLI flags.
Quick Answer: Scale Without Distortion
The fastest way to resize a video while keeping its aspect ratio intact:
ffmpeg -i input.mp4 -vf "scale=-2:1080" output.mp4
The -2 tells FFmpeg to calculate the width automatically based on the input's aspect ratio, rounding to the nearest even number (which video codecs require). Your 4:3 input becomes 1440x1080. Your 16:9 input becomes 1920x1080. No distortion.
What the -2 Value Actually Does
FFmpeg's scale filter takes width and height as arguments: scale=width:height. When you set either dimension to -1 or -2, FFmpeg calculates that dimension from the other one using the original aspect ratio.
The difference between -1 and -2:
-
-1calculates the value, but it might produce an odd number (e.g., 1441) -
-2does the same calculation but rounds to the nearest even number
Odd pixel dimensions cause encoding failures with H.264 and H.265. Always use -2, not -1.
# Scale to 720p height, auto-calculate width
ffmpeg -i input.mp4 -vf "scale=-2:720" output.mp4
# Scale to 1280 width, auto-calculate height
ffmpeg -i input.mp4 -vf "scale=1280:-2" output.mp4
# Scale to 4K height
ffmpeg -i input.mp4 -vf "scale=-2:2160" output.mp4
force_original_aspect_ratio: Fit or Fill
Sometimes you need the output to be exactly 1920x1080, no exceptions. But your input is 4:3. The force_original_aspect_ratio parameter handles this without stretching.
decrease shrinks the video to fit inside the target dimensions:
ffmpeg -i input.mp4 -vf "scale=1920:1080:force_original_aspect_ratio=decrease" output.mp4
increase enlarges the video to fill the target dimensions:
ffmpeg -i input.mp4 -vf "scale=1920:1080:force_original_aspect_ratio=increase" output.mp4
Letterboxing with pad
If you need exactly 1920x1080 with black bars (letterboxing), chain the pad filter:
ffmpeg -i input.mp4 -vf "scale=1920:1080:force_original_aspect_ratio=decrease,pad=1920:1080:(ow-iw)/2:(oh-ih)/2:black" output.mp4
Common Resolution Targets
| Target | Command |
|---|---|
| 480p (SD) | scale=-2:480 |
| 720p (HD) | scale=-2:720 |
| 1080p (Full HD) | scale=-2:1080 |
| 2160p (4K) | scale=-2:2160 |
Scale via the FFmpeg Micro API
If you don't want to install FFmpeg or manage a server, you can resize videos through an API call:
curl -X POST https://api.ffmpeg-micro.com/v1/transcodes \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"inputs": [{"url": "https://example.com/video.mp4"}],
"outputFormat": "mp4",
"options": [
{"option": "-vf", "argument": "scale=-2:1080"}
]
}'
FFmpeg Micro is a cloud API that accepts the same FFmpeg filters as the CLI. No FFmpeg installation, no server management.
FAQ
Does ffmpeg scale preserve aspect ratio by default?
No. The default scale=width:height stretches the video to fit both dimensions. Use -2 for auto-calculation or force_original_aspect_ratio to prevent distortion.
What's the difference between -s and -vf scale in FFmpeg?
-s 1920x1080 sets exact output dimensions and can distort. -vf "scale=-2:1080" calculates one dimension from the other to keep the aspect ratio.
Can I resize video through an API without installing FFmpeg?
Yes. FFmpeg Micro is a cloud API that accepts the same FFmpeg filters. Send a POST to /v1/transcodes with options: [{"option": "-vf", "argument": "scale=-2:1080"}] and get back the resized video.
Top comments (0)