crop=ih*9/16:ih cuts a centered 608x1080 slice from a 1920x1080 frame; for black bars, run cropdetect with round=2 first. ReelSDK runs the same crop for $0.02 per compute minute, and its free vertical converter crops in your browser.
Crop a video with ffmpeg: 9:16, square and black bars
crop=w:h:x:y keeps one rectangle of every frame, centered when x and y are left out, and crop=ih:ih makes a 1080x1080 square. ReelSDK's API ran the 9:16 crop of a 10-second clip in about 7 seconds.
GuidesUpdated
ffmpeg -i landscape.mp4 -vf "crop=ih*9/16:ih" -c:a copy vertical.mp4ih*9/16 is the input height times 9/16, 607.5 on a 1080-pixel-high frame, and ffmpeg wrote 608. With no x and y the crop is centered, and -c:a copy keeps the audio as it was.
Variations
The other commands you will need
Crop to a square
Width and height both set to the input height give a centered 1080x1080 square.
square crop ffmpeg -i landscape.mp4 -vf "crop=ih:ih" -c:a copy square.mp4Crop a fixed region
x and y count from the top-left corner of the frame.
960:540:960:0keeps the top-right quarter of a 1920x1080 frame.region crop ffmpeg -i landscape.mp4 -vf "crop=960:540:960:0" -c:a copy corner.mp4Find and remove black bars
cropdetectprints acrop=value for the frames it reads;-f null -throws the output away. Our letterboxed clip holds a 1920x804 picture between 138-pixel bars. Withround=2cropdetect printedcrop=1920:804:0:138, and that crop gave a 1920x804 file.black bars ffmpeg -i letterboxed.mp4 -vf cropdetect=round=2 -f null - ffmpeg -i letterboxed.mp4 -vf crop=1920:804:0:138 -c:a copy nobars.mp4
The flags
The flags in these commands
| Flag | What it does | Used here |
|---|---|---|
crop=w:h:x:y | Keeps a w by h rectangle whose top-left corner sits at x, y | Every crop |
iw, ih | The input width and height, for use in expressions | ih*9/16, ih:ih |
| x and y left out | Default to (in_w-out_w)/2 and (in_h-out_h)/2, which centers the crop | 9:16 and square |
exact=1 | Crops subsampled video at the exact sizes and offsets instead of rounding them down | Not used |
cropdetect | Reads frames and prints the crop that removes dark borders | Black bars |
round=2 | cropdetect: width and height must divide by this; the default is 16 | Black bars |
limit | cropdetect: the level below which a pixel counts as black, 24 on a 0 to 255 scale by default | Default |
-c:a copy | Copies the audio; only the video is encoded again | Every crop |
Source: ffmpeg filters: crop and cropdetect, checked November 2026.
How crop reads w:h:x:y
The crop filter takes the output width and height first, then the position of the top-left corner. Leave x and y out and ffmpeg fills them in as (in_w-out_w)/2 and (in_h-out_h)/2, a centered crop. Width and height default to the full input, so crop=ih:ih on a landscape frame is a centered square.
Every value can be an expression. ih*9/16 came to 607.5 on our clip and ffmpeg wrote 608 columns, so the file is a hair wider than 9:16. For a full-size 1080x1920 export, scale the crop up afterwards, as the vertical video guide does in one filter chain.
A crop always re-encodes the video
Filters work on decoded frames, so cropping means decoding the video and encoding it again; -c copy can't crop. Only the audio passes through untouched with -c:a copy.
With no -c:v, ffmpeg encoded our MP4 crops with libx264 at its defaults: CRF 23 and the medium preset. Add -crf and -preset to choose size and speed yourself; the CRF guide measures what each step does.
Black bars and cropdetect
cropdetect looks for rows and columns darker than its limit, 24 on a 0 to 255 scale by default, and prints the smallest crop that keeps the rest. It skips the first 2 frames and prints a line for every frame after that; take the last one, which by default covers the largest picture area seen in the whole run.
Our test file has a 1920x804 picture inside a 1920x1080 frame. With the default round=16, cropdetect printed crop=1920:800:0:140: 804 doesn't divide by 16, so it cut 2 rows of picture at the top and 2 at the bottom. With round=2 it printed the exact crop=1920:804:0:138.
Crop, scale or pad
Crop throws pixels away, scale resizes all of them, and pad adds a border around them. To turn landscape footage into a vertical video you either crop the sides off, as above, or fit the whole frame and pad it, which keeps everything but leaves bars. The resize guide has the fit-and-pad command and the aspect ratio catch that comes with it.
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 crop 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", "crop=ih*9/16:ih", "-c:a", "copy",
"vertical.mp4"
],
"outputs": ["vertical.mp4"]
}'FAQ
Questions, answered
How do I crop a video to 9:16 with ffmpeg?
Use -vf "crop=ih*9/16:ih". It keeps the full height and a centered slice of the width: 608x1080 from a 1920x1080 clip. Scale it to 1080x1920 afterwards if the platform asks for that size.
How do I remove black bars from a video?
Run ffmpeg -i in.mp4 -vf cropdetect=round=2 -f null -, take the last crop= value it prints and pass it to the crop filter. On our letterboxed clip that was crop=1920:804:0:138.
Why is cropdetect a few pixels off?
Its round option defaults to 16, so the width and height it prints divide by 16. Our 804-pixel-high picture came back as 800 rows. Set round=2 for an exact crop that still has even sizes.
Can ffmpeg crop a video without re-encoding?
Not with the crop filter. Filters work on decoded frames, so the video stream is encoded again. The audio can be copied as it is with -c:a copy.
Can I crop a video without installing ffmpeg?
Yes. Send the same args to POST https://api.reelsdk.com/v1/ffmpeg with the video URL in inputs and the cropped file in outputs. 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.
- Resize a video with ffmpegScale a video with scale=w:h: keep the aspect ratio with -2, fit a 1080x1920 frame with pad, and fix the odd-size error.
- 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.
- Remove a logo from a video with ffmpegHide a fixed logo or timestamp with delogo or removelogo, find its exact box with show=1, or crop it away, and know what each leaves behind.
- Rotate and flip a video with ffmpegRotate a video 90 or 180 degrees or mirror it with transpose, hflip and vflip, or change only the rotation flag without re-encoding.
- Vertical video converterTurn a landscape video into a vertical one in your browser, with a blurred background, free and without uploading it.
- Vertical videoTurn 16:9 footage into a 1080x1920 vertical video with a blurred fill in one ffmpeg call, about a quarter cent per 30 s clip.
- 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.
- 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.
