Scale with force_original_aspect_ratio=decrease, then pad: a 1920x1080 picture fits a 1080x1920 frame at 1080x608, with black bars above and below. At ReelSDK's $0.02 per compute minute, a 10-second clip costs under three quarters of a cent.
Letterbox and pad a video with ffmpeg
Two filters do it: scale shrinks a 16:9 picture until it fits a 9:16 frame, and pad fills the rest with black or any colour. ReelSDK's free vertical video converter does the same in your browser, with bars or a blurred copy behind the picture. cropdetect finds the bars again, but its default rounding of 16 can cut 4 px of real picture from each side of a 1080-wide frame.
GuidesUpdated
ffmpeg -i in.mp4 -vf "scale=1080:1920:force_original_aspect_ratio=decrease,pad=1080:1920:(ow-iw)/2:(oh-ih)/2:color=black,setsar=1" \
-c:v libx264 -crf 20 -preset veryfast -c:a copy -movflags +faststart tall.mp4force_original_aspect_ratio=decrease scales the 1920x1080 frame down to 1080x608 so it fits inside 1080x1920, and pad centres it with (ow-iw)/2:(oh-ih)/2. tall.mp4 came out at 1080x1920, with 656 px of black above and below the picture.
Variations
The other commands you will need
9:16 into 16:9 with bars at the sides
The same filters with the sizes swapped: a 1080x1920 clip becomes a 608x1080 picture at x=656, centred in a 1920x1080 frame.
pillarbox ffmpeg -i clip.mp4 -vf "scale=1920:1080:force_original_aspect_ratio=decrease,pad=1920:1080:(ow-iw)/2:(oh-ih)/2:color=black,setsar=1" \ -c:v libx264 -crf 20 -preset veryfast -c:a copy -movflags +faststart wide.mp4A square on white
A negative x or y tells pad to centre the picture, so
-1:-1saves typing the expressions.colortakes a name or a hex value; this one is white, 1080x1080.square ffmpeg -i in.mp4 -vf scale=1080:1080:force_original_aspect_ratio=decrease,pad=1080:1080:-1:-1:color=white,setsar=1 \ -c:v libx264 -crf 20 -preset veryfast -c:a copy -movflags +faststart square.mp4Measure the bars, then crop them off
cropdetect prints a
crop=value for each frame. Setround=2: with the default of 16 it reported 1072 px wide on our letterboxed file, 8 px narrower than the real picture. The exact crop gives back the 1080x608 picture.remove bars ffmpeg -i tall.mp4 -vf cropdetect=round=2 -f null - 2>&1 | grep -o 'crop=[0-9:]*' | sort | uniq -c # 291 crop=1080:608:0:656 ffmpeg -i tall.mp4 -vf crop=1080:608:0:656 \ -c:v libx264 -crf 20 -preset veryfast -c:a copy -movflags +faststart uncropped.mp4
The flags
The filters and options in these commands
| Flag | What it does | Used here |
|---|---|---|
pad=1080:1920 | Size of the output frame, bars included | Letterbox |
(ow-iw)/2:(oh-ih)/2 | x and y of the picture; half the spare room centres it | Letterbox, pillarbox |
color=black | Bar colour, a name or hex; black is the default | All three |
force_original_aspect_ratio=decrease | Shrinks the picture until both sides fit, keeping its shape | All three |
-1:-1 | A negative x or y centres the picture | Square |
setsar=1 | Square pixels, so players show the frame at its real shape | All three |
cropdetect=round=2 | Prints the picture area; round defaults to 16 | Remove bars |
crop=1080:608:0:656 | Width, height, x and y of the area to keep | Remove bars |
Source: ffmpeg filters: pad, scale, cropdetect, crop, checked November 2026.
Letterbox or pillarbox
Bars above and below are a letterbox; bars at the sides are a pillarbox. Both come from the same two steps: scale the picture until it fits the frame, then pad. Skip the first step and pad stops with "Padded dimensions cannot be smaller than input dimensions."
The ffmpeg manual on pad: "If x or y evaluate to a negative number, they'll be changed so the input image is centered on the padded area." That is why -1:-1 and (ow-iw)/2:(oh-ih)/2 give the same result. Black is the default colour.
The cropdetect rounding trap
cropdetect looks for rows and columns darker than its limit and prints the area that is left. By default it rounds that area to a multiple of 16. On our letterboxed file the picture is 1080 px wide, which is not a multiple of 16, so it printed crop=1072:608:4:656 and would have cut 4 px of picture from each side.
With round=2 it printed the exact crop=1080:608:0:656 on almost every frame and crop=608:1080:656:0 on the pillarboxed one. Count the values over the whole clip, as the fourth command does, because dark scenes can shrink the area on a few frames.
Bars or a blurred fill
Bars keep every pixel of the picture and encode small: tall.mp4 is under 3 MB for 10 seconds of vertical HD. For social feeds, a blurred copy of the clip often looks better than black; the blurred background guide does the same fit with gblur behind it.
Either way, the args run unchanged on the API, billed per compute second; see pricing.
Without installing ffmpeg
The same command as one API call
Send the first command's args to POST /v1/ffmpeg with the video's URL in inputs. Each job runs ffmpeg 8.1 on a fresh machine at $0.02 per compute minute, billed per second; this one finished in about 17 seconds and cost under three quarters of a cent.
curl "https://api.reelsdk.com/v1/ffmpeg?wait=60" \
-H "Authorization: Bearer $REELSDK_KEY" \
--json '{
"inputs": {
"in.mp4": "https://api.reelsdk.com/f/lib/demo/landscape.mp4"
},
"args": [
"-i", "in.mp4", "-vf",
"scale=1080:1920:force_original_aspect_ratio=decrease,pad=1080:1920:(ow-iw)/2:(oh-ih)/2:color=black,setsar=1",
"-c:v", "libx264", "-crf", "20", "-preset", "veryfast", "-c:a", "copy",
"-movflags", "+faststart", "tall.mp4"
],
"outputs": ["tall.mp4"]
}'FAQ
Questions, answered
How do I turn a 16:9 video into 9:16 with black bars?
Use -vf "scale=1080:1920:force_original_aspect_ratio=decrease,pad=1080:1920:(ow-iw)/2:(oh-ih)/2". A 1920x1080 picture becomes 1080x608, with 656 px of black above and below.
Why does pad say padded dimensions cannot be smaller than input dimensions?
pad only adds space; it cannot shrink. Our 1920x1080 clip padded to 1080x1920 without a scale stopped with exactly that error. Scale first with force_original_aspect_ratio=decrease so the picture fits inside the padded size.
Why did cropdetect cut off part of my picture?
Its round option defaults to 16, so a 1080 px wide picture came back as 1072. Run cropdetect=round=2 to get the exact size.
Can the bars be a colour other than black?
Yes. pad takes color=white, a colour name or a hex value such as color=0x1a1a1a.
- 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.
- Crop a video with ffmpegCut a frame down with crop=w:h:x:y: a centered 9:16 or square crop, a fixed region, and cropdetect to find black bars.
- 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.
- ffmpeg -filter_complex explainedLabels, commas and semicolons: how a filtergraph wires inputs to outputs, with four working graphs and the errors they fix.
- 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.
- Vertical video converterTurn a landscape video into a vertical one in your browser, with a blurred background, free and without uploading it.
- 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.
- ReelSDK vs self-hosted FFmpegTranscoding a minute of 1080p to 720p takes about 24 seconds of compute: about 0.8 cents on ReelSDK, about a tenth of a cent on a busy 4 vCPU box. Below about 11,000 minutes a month, the API costs less than an always-on box.
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.
