How to Crop a Video with FFmpeg (Plus an Easier Mac Alternative)
How to Crop a Video with FFmpeg
Cropping trims away the parts of the frame you don't want — black bars, a watermark in the corner, dead space around the subject, or just reframing 16:9 footage into a square for Instagram. If you need to crop a video with FFmpeg, the entire job comes down to one filter: crop. Once you understand its four numbers, you can cut any rectangle out of any video from the command line.
This guide explains the FFmpeg crop filter syntax exactly, gives you copy-paste commands for the most common situations, shows how to find the right coordinates automatically, and covers how cropping interacts with quality and file size. At the end, we'll look at an easier path for Mac users who'd rather not touch a terminal.
If you're also resizing while you're at it, our FFmpeg resize video guide pairs perfectly with everything below.
The FFmpeg Crop Filter Syntax: crop=w:h:x:y
The crop filter takes up to four values, in this order:
crop=w:h:x:y
w— the width of the output (the rectangle you keep), in pixels.h— the height of the output, in pixels.x— the horizontal offset: how many pixels from the left edge the crop begins.y— the vertical offset: how many pixels from the top edge the crop begins.
The single most important thing to internalize: the origin (0, 0) is the top-left corner of the frame. X increases as you move right, Y increases as you move down. So crop=640:480:200:100 means "keep a 640×480 rectangle, starting 200 px from the left and 100 px from the top."
If you leave out x and y, FFmpeg centers the crop automatically — which is exactly what you want most of the time. You can also use the built-in variables in_w and in_h (input width and height, abbreviated iw and ih) to do math relative to the source dimensions instead of hard-coding numbers.
Basic FFmpeg Crop Command
Here's the simplest possible crop. Keep a 640×480 region, offset 200 px right and 100 px down from the top-left corner:
ffmpeg -i input.mp4 -vf "crop=640:480:200:100" output.mp4
That's the whole crop command. The -vf flag (short for -filter:v, the video filter) is how you apply crop. Swap input.mp4 for your file, adjust the four numbers, and you're done.
A quick note on the audio: by default FFmpeg re-encodes audio too. To keep the original audio untouched and only re-encode the video, add -c:a copy:
ffmpeg -i input.mp4 -vf "crop=640:480:200:100" -c:a copy output.mp4
This is faster and avoids any audio quality loss, since the audio stream is copied through verbatim.
Center Crop: Trim Evenly From Every Side
When you want to shave a uniform border off the frame, do the math with in_w and in_h and let FFmpeg center the result. This command trims 100 px from each side (200 px total off both width and height):
ffmpeg -i input.mp4 -vf "crop=in_w-200:in_h-200" output.mp4
Because x and y are omitted, FFmpeg centers the remaining rectangle automatically. This is the cleanest way to remove an even border without measuring pixel offsets by hand.
You can also crop to a percentage of the original. To keep the center 80% of the frame:
ffmpeg -i input.mp4 -vf "crop=in_w*0.8:in_h*0.8" output.mp4
Crop to a Square or Social Aspect Ratio with FFmpeg
Reframing horizontal footage for social platforms is one of the most common reasons people crop a video with FFmpeg. The trick is to express the crop in terms of in_h (the source height) so it works regardless of resolution.
Crop landscape video to a centered square (1:1) — Instagram feed:
ffmpeg -i input.mp4 -vf "crop=in_h:in_h" output.mp4
This takes a square whose side equals the video's height and centers it horizontally — perfect for turning 16:9 into 1:1 without stretching.
Crop to vertical 9:16 — Reels, TikTok, Shorts:
ffmpeg -i input.mp4 -vf "crop=in_h*9/16:in_h" output.mp4
This carves a 9:16 portrait window out of the center of a landscape source. Because cropping discards the sides rather than squeezing them, your subject stays correctly proportioned — no warping.
If your subject isn't centered, add explicit x/y offsets to slide the crop window over to frame them properly, e.g. crop=in_h*9/16:in_h:600:0.
Combine Crop with Scale and Quality Settings
The crop filter rarely works alone. The most useful combination is crop then scale — cut the region you want, then resize it to a standard output dimension. Filters in a -vf chain run left to right, separated by commas:
ffmpeg -i input.mp4 -vf "crop=in_h:in_h,scale=1080:1080" -c:a copy output.mp4
This crops to a center square first, then scales that square up or down to a clean 1080×1080. For more on the scale half of this chain, see our FFmpeg resize video guide.
Since any crop forces a video re-encode anyway, it's the perfect moment to control quality and file size with -crf (Constant Rate Factor). Lower CRF means higher quality and larger files; 18–23 is the sweet spot for most footage:
ffmpeg -i input.mp4 -vf "crop=in_h:in_h" -c:v libx264 -crf 20 -c:a copy output.mp4
To crop and shrink in one pass with the more efficient H.265 codec:
ffmpeg -i input.mp4 -vf "crop=in_h:in_h" -c:v libx265 -crf 26 -c:a copy output.mp4
For a deeper look at choosing CRF values and codecs to shrink files, our FFmpeg compress video guide walks through the tradeoffs, and the AV1 vs H.265 comparison helps you pick a modern codec.
How to Find the Right Crop Coordinates
Guessing pixel offsets is tedious. FFmpeg has two built-in ways to find them.
1. The cropdetect filter (best for removing black bars):
Run cropdetect against your file and FFmpeg will analyze the frames and print a suggested crop rectangle:
ffmpeg -i input.mp4 -vf cropdetect -f null -
Watch the console output — you'll see lines ending with something like crop=1920:800:0:140. That's FFmpeg telling you exactly what crop=w:h:x:y will strip the letterbox bars. Copy that string straight into your real command:
ffmpeg -i input.mp4 -vf "crop=1920:800:0:140" -c:a copy output.mp4
2. Preview a crop before committing:
You don't have to write a file to check your numbers. Use ffplay (ships with FFmpeg) to preview the crop live:
ffplay -i input.mp4 -vf "crop=in_h:in_h"
Tweak the values, re-run, and only encode the final output once it looks right. This saves a lot of wasted re-encodes.
Crop Is Lossless Geometry — But the Re-Encode Isn't
A point worth being precise about: the crop operation itself is lossless. It simply discards the pixels outside your rectangle; the pixels you keep are unchanged. There's no resampling, no blurring.
However, cropping requires FFmpeg to re-encode the video stream (you can't just copy it through, because its dimensions changed). That re-encode is where quality and file size are actually decided — by your codec, CRF, and bitrate, not by the crop. So:
- Keep
-c:a copyto preserve audio exactly and speed things up. - Use
-c:v libx264 -crf 18(or-crf 20) when you want the output visually indistinguishable from the source. - Drop to
libx265 -crf 26when you'd rather trade a tiny bit of quality for a much smaller file.
In other words, "cropping lost quality" is almost always a re-encoding setting, not the crop. Dial in your CRF and the cropped result looks as crisp as the original region.
An Easier Way on Mac: How Compresto Helps
FFmpeg is powerful, but the command line isn't for everyone — and once you've cropped a clip, you usually still want to shrink it before sharing or archiving. That's where a GUI saves time.
Compresto is a native macOS app that wraps the same hardware-accelerated engine behind a drag-and-drop interface. It doesn't replace the FFmpeg crop filter — to-the-pixel cropping is still best done with the commands above — but it's the easiest way to compress and resize the result without memorizing a single flag.
The typical workflow: crop your clip with one of the FFmpeg commands here, then drop the output into Compresto to compress it down for upload. Because Compresto uses Apple's VideoToolbox for hardware-accelerated HEVC encoding on Apple Silicon, that compression pass is fast and the files come out dramatically smaller with no perceptible quality loss. It also handles batch video compression across whole folders, plus images, GIFs, and PDFs.
If you came to FFmpeg mainly to make files smaller rather than to reframe them, our walkthrough on how to compress videos using FFmpeg and an easier alternative compares both approaches side by side. And if your source happens to be an old phone clip, you may first need to convert 3GP to MP4 before cropping.
FFmpeg Crop Video: Quick Reference
| Goal | Command |
|---|---|
| Basic crop, explicit offsets | -vf "crop=640:480:200:100" |
| Center crop, trim 100 px per side | -vf "crop=in_w-200:in_h-200" |
| Center square (1:1) | -vf "crop=in_h:in_h" |
| Vertical 9:16 | -vf "crop=in_h*9/16:in_h" |
| Crop then resize | -vf "crop=in_h:in_h,scale=1080:1080" |
| Detect crop (remove black bars) | -vf cropdetect -f null - |
| Preview crop live | ffplay -vf "crop=in_h:in_h" |
Keep audio with -c:a copy and control quality with -c:v libx264 -crf 20 on any of these.
FAQ: Cropping Video with FFmpeg
Q: How do I crop a video with FFmpeg?
Use the crop filter: ffmpeg -i input.mp4 -vf "crop=640:480:200:100" output.mp4. The four values are width, height, x-offset, and y-offset, where the offset is measured from the top-left corner of the frame.
Q: What does crop=w:h:x:y mean in FFmpeg?
It defines the rectangle to keep. w is the output width, h is the output height, x is how many pixels from the left edge the crop starts, and y is how many pixels from the top edge it starts. The origin (0, 0) is the top-left corner.
Q: How do I crop a video to the center with FFmpeg?
Omit x and y and let FFmpeg center automatically: ffmpeg -i input.mp4 -vf "crop=in_w-200:in_h-200" output.mp4. This trims 100 px from each side. When x and y are not given, FFmpeg centers the crop by default.
Q: Does cropping a video with FFmpeg reduce quality?
The crop itself is a lossless geometry change — it just discards pixels outside the rectangle. But cropping forces a re-encode of the video stream, and that re-encode is where quality and file size are determined. Use -crf 18-23 with libx264/libx265 to keep quality high.
Q: How do I find the right crop coordinates?
Use the cropdetect filter to have FFmpeg suggest values: ffmpeg -i input.mp4 -vf cropdetect -f null -. It analyzes the frames and prints a suggested crop=w:h:x:y line, which is ideal for automatically removing black bars.
Want to skip the terminal entirely for the compression step? Download Compresto for Mac and shrink your cropped clips with hardware-accelerated HEVC encoding — fast, drag-and-drop, no commands to memorize.