How to Crop and Resize Video with FFmpeg

You need to resize a video to 720p. Or crop a landscape clip to vertical for TikTok. FFmpeg handles both, but the syntax trips up even experienced developers, especially around aspect ratios and pixel dimension requirements.
This guide covers the three filters you actually need: scale, crop, and pad. Every example includes a working CLI command and the equivalent FFmpeg Micro API call.
How to Resize Video with the FFmpeg Scale Filter
The scale filter sets the output width and height in pixels.
ffmpeg -i input.mp4 -vf "scale=1280:720" -c:v libx264 -crf 23 output.mp4
This forces the video to exactly 1280x720. If your source has a different aspect ratio, the output gets stretched. To preserve the aspect ratio, use -2 for the dimension you want FFmpeg to calculate automatically:
ffmpeg -i input.mp4 -vf "scale=1280:-2" -c:v libx264 -crf 23 output.mp4
Why -2 instead of -1? H.264 and H.265 encoders require even pixel dimensions. Using -1 can produce an odd height like 719, which crashes the encode. The -2 flag rounds to the nearest even number.
The same resize via FFmpeg Micro's API:
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/input.mp4"}],
"outputFormat": "mp4",
"options": [
{"option": "-vf", "argument": "scale=1280:-2"},
{"option": "-c:v", "argument": "libx264"},
{"option": "-crf", "argument": "23"}
]
}'
If you just need a standard resolution without fine-tuning, use preset mode:
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/input.mp4"}],
"outputFormat": "mp4",
"preset": {"quality": "high", "resolution": "720p"}
}'
How to Crop Video with FFmpeg
The crop filter cuts a rectangular area from your video. The syntax is crop=width:height:x:y, where x and y define the top-left corner.
To crop a centered 1080x1080 square from a 1920x1080 video:
ffmpeg -i input.mp4 -vf "crop=1080:1080:(iw-1080)/2:(ih-1080)/2" -c:v libx264 -crf 23 output.mp4
The expressions iw and ih refer to the input width and height. This formula centers the crop regardless of the source resolution.
The equivalent 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/input.mp4"}],
"outputFormat": "mp4",
"options": [
{"option": "-vf", "argument": "crop=1080:1080:(iw-1080)/2:(ih-1080)/2"},
{"option": "-c:v", "argument": "libx264"},
{"option": "-crf", "argument": "23"}
]
}'
Converting Horizontal Video to Vertical for TikTok and Reels
You have a 16:9 landscape video and need 9:16 for TikTok, Instagram Reels, or YouTube Shorts. Two approaches, depending on whether you're okay losing the sides.
Center crop (keeps the middle, loses the edges):
ffmpeg -i input.mp4 -vf "crop=ih*9/16:ih,scale=1080:1920" -c:v libx264 -crf 23 vertical.mp4
This crops a 9:16 slice from the center of the frame, then scales it to 1080x1920. You lose the left and right edges, but the subject stays in focus.
Scale and pad (keeps everything, adds black bars):
ffmpeg -i input.mp4 -vf "scale=1080:-2,pad=1080:1920:0:(oh-ih)/2:black" -c:v libx264 -crf 23 vertical.mp4
This shrinks the video to 1080px wide (maintaining aspect ratio), then pads the top and bottom with black bars to fill the 1080x1920 frame. Nothing gets cropped, but you get letterboxing.
Both work with the FFmpeg Micro API. Just swap the -vf argument:
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/input.mp4"}],
"outputFormat": "mp4",
"options": [
{"option": "-vf", "argument": "crop=ih*9/16:ih,scale=1080:1920"},
{"option": "-c:v", "argument": "libx264"},
{"option": "-crf", "argument": "23"}
]
}'
Common Platform Dimensions
| Platform | Aspect Ratio | Resolution |
|---|---|---|
| TikTok / Reels / Shorts | 9:16 | 1080x1920 |
| Instagram Feed | 1:1 | 1080x1080 |
| YouTube / Standard | 16:9 | 1920x1080 |
| Twitter/X Video | 16:9 or 1:1 | 1280x720 or 720x720 |
Common Pitfalls When Cropping and Resizing
Odd pixel dimensions break H.264 encoding. If your crop or scale produces an odd width or height, libx264 fails with a cryptic error about "not divisible by 2." Always use -2 for auto-calculated dimensions, or make sure your values are even.
Filter order matters. crop then scale gives different results than scale then crop. If you want to grab the center of a video and upscale it, crop first. If you want to shrink and then trim edges, scale first. Think about what the pixel values mean at each step in the chain.
Upscaling degrades quality. Scaling a 480p video to 1080p doesn't add detail. It just makes pixels bigger. If you must upscale, keep the factor under 2x and use the lanczos algorithm for sharper results: scale=1920:1080:flags=lanczos.
DAR vs SAR confusion. Some video files store a display aspect ratio (DAR) that differs from the actual pixel dimensions. A 720x576 file might display as 16:9. FFmpeg's scale filter works on actual pixels, not the display ratio. Check with ffprobe -show_entries stream=width,height,display_aspect_ratio input.mp4 before assuming dimensions.
FAQ
What is the difference between -s and -vf scale in FFmpeg?
The -s flag and the scale filter both resize video. But -s doesn't support expressions like -2 for auto-calculation or flags=lanczos for better interpolation. Use the scale filter for anything beyond basic fixed-dimension resizing.
Can I crop and resize in the same FFmpeg command?
Yes. Chain the filters with a comma: -vf "crop=1080:1080:(iw-1080)/2:0,scale=720:720". FFmpeg processes filters left to right, so the crop happens first, then the resize.
How do I resize video without re-encoding?
You can't. Resizing changes pixel data, which requires decoding and re-encoding. If you only need to change the container format (MP4 to MOV, for example) without resizing, use -c copy instead.
Does FFmpeg Micro support crop and resize filters?
FFmpeg Micro accepts any valid FFmpeg filter in the options array of the POST /v1/transcodes endpoint. Pass your -vf filter string exactly as you would on the CLI. No FFmpeg installation, no server to manage.
Skip the Server Setup
If you're building crop and resize into an app or automation workflow, FFmpeg Micro handles the infrastructure for you. One API call, any filter combination, results in minutes. Sign up for the free tier and run your first resize in under 60 seconds.
For a deeper look at FFmpeg encoding and filter fundamentals, check out the Learn FFmpeg course.
About Javid Jamae
Founder & CEO at FFmpeg Micro
Javid is a software engineer, author, and entrepreneur with over 25 years of professional software development experience across enterprise, startup, and consulting environments. He founded FFmpeg Micro to make video processing accessible to developers through a simple, automation-first REST API.
You might also like

How to Trim and Cut Video with FFmpeg (CLI + API Guide)
Learn how to trim and cut video with FFmpeg using -ss, -t, and -to flags. Covers keyframe-accurate cutting, stream copy vs re-encode, and the FFmpeg Micro API.

How to Compress Video with FFmpeg Without Losing Quality
Learn how to compress video with FFmpeg using CRF, two-pass encoding, and preset tuning. Reduce file size by 50-80% without visible quality loss.

How to Speed Up or Slow Down Video with FFmpeg
Learn how to change video speed with FFmpeg using setpts and atempo filters. Covers 2x speedup, slow motion, audio sync, and API-based processing.
Ready to process videos at scale?
Start using FFmpeg Micro's simple API today. No infrastructure required.
Get Started Free