FFmpeg pad Filter: Letterbox and Pillarbox Video for Any Aspect Ratio

You have got a 4:3 video that needs to be 16:9. Or a landscape clip that needs to fit a 9:16 vertical frame. Scaling alone either distorts the image or leaves the wrong dimensions. FFmpeg’s pad filter adds bars (black or any color) to fill the gap without touching a single pixel of your actual video.
Quick Answer: Pad to a Target Aspect Ratio
Letterbox a 4:3 video into a 16:9 frame with centered black bars:
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
This first scales the video to fit inside 1920x1080 without distortion, then pads the remaining space with black. Two filters, one command.
How the pad Filter Works
The pad filter syntax:
pad=width:height:x:y:color
- width and height set the total canvas size
- x and y position the video on that canvas
- color fills the empty space (default is black)
A concrete example. You have a 1280x720 video and you want it centered on a 1920x1080 canvas:
ffmpeg -i input.mp4 -vf "pad=1920:1080:320:180:black" output.mp4
The math: (1920-1280)/2 = 320 for x, (1080-720)/2 = 180 for y. But you don't need to do that math yourself.
Dynamic Centering with Expressions
Instead of hardcoding pixel values, use FFmpeg's built-in variables:
ffmpeg -i input.mp4 -vf "pad=1920:1080:(ow-iw)/2:(oh-ih)/2:black" output.mp4
ow= output width (the pad canvas width, 1920)oh= output height (the pad canvas height, 1080)iw= input width (whatever your video is)ih= input height (whatever your video is)
This centers any input resolution on the target canvas. Works whether your input is 640x480, 1280x720, or 1440x1080.
Letterboxing vs Pillarboxing
Two terms, different orientations:
- Letterboxing adds horizontal bars (top and bottom). Happens when a wide video goes into a taller frame.
- Pillarboxing adds vertical bars (left and right). Happens when a narrow or square video goes into a wider frame.
The pad filter handles both the same way. A 1080x1080 square video on a 1920x1080 canvas gets pillarboxed automatically:
ffmpeg -i square.mp4 -vf "pad=1920:1080:(ow-iw)/2:(oh-ih)/2:black" output.mp4
Result: 420 pixels of black on each side, video perfectly centered.
The scale + pad Combo
In practice, you almost always need scale before pad. Your input won't match the target height or width exactly, so you scale it down to fit first, then pad the rest.
The reliable pattern:
ffmpeg -i input.mp4 -vf "scale=WIDTH:HEIGHT:force_original_aspect_ratio=decrease,pad=WIDTH:HEIGHT:(ow-iw)/2:(oh-ih)/2:COLOR" output.mp4
Replace WIDTH, HEIGHT, and COLOR for your target.
Social Media Aspect Ratio Recipes
Copy-paste commands for every major platform:
YouTube / landscape (16:9):
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
Instagram Reels / TikTok / Shorts (9:16):
ffmpeg -i input.mp4 -vf "scale=1080:1920:force_original_aspect_ratio=decrease,pad=1080:1920:(ow-iw)/2:(oh-ih)/2:black" output.mp4
Instagram square (1:1):
ffmpeg -i input.mp4 -vf "scale=1080:1080:force_original_aspect_ratio=decrease,pad=1080:1080:(ow-iw)/2:(oh-ih)/2:black" output.mp4
Twitter / X video (16:9 at 1280x720):
ffmpeg -i input.mp4 -vf "scale=1280:720:force_original_aspect_ratio=decrease,pad=1280:720:(ow-iw)/2:(oh-ih)/2:black" output.mp4
Custom Bar Colors
Black is the default, but you can use any color.
# White bars
ffmpeg -i input.mp4 -vf "pad=1920:1080:(ow-iw)/2:(oh-ih)/2:white" output.mp4
# Hex color (dark blue)
ffmpeg -i input.mp4 -vf "pad=1920:1080:(ow-iw)/2:(oh-ih)/2:0x1a1a2e" output.mp4
# Brand color (any 6-digit hex)
ffmpeg -i input.mp4 -vf "pad=1920:1080:(ow-iw)/2:(oh-ih)/2:0xff6600" output.mp4
Branded padding makes automated social media content look intentional instead of lazy.
Pad via the FFmpeg Micro API
If you are automating video processing in a pipeline with n8n, Make, or your own code, you can run the same pad filter through an API call. No FFmpeg installation needed.
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=1080:1920:force_original_aspect_ratio=decrease,pad=1080:1920:(ow-iw)/2:(oh-ih)/2:black"}
]
}'
Same filter chain, no server to manage. The API accepts the same FFmpeg filter expressions you would use on the CLI. Get a free API key at ffmpeg-micro.com to try it.
Common Pitfalls
Padding without scaling first. If your input is larger than the pad dimensions, FFmpeg throws an error or produces garbage output. Always scale to fit before padding.
Odd dimensions. H.264 and H.265 require even pixel dimensions. If your pad math produces an odd number, encoding fails. Use even numbers for width and height, and pair scale with -2 to keep things safe.
Using pad when you need crop. Pad adds space. Crop removes it. If you want to cut a 16:9 video down to 9:16 (removing the sides), use crop. If you want to fit the entire 16:9 video into a 9:16 frame with bars, use scale + pad.
Forgetting color in WebM. In most containers, omitting the color defaults to black. But in WebM with alpha support, you can get transparent or garbage pixels. Specify the color explicitly to be safe.
FAQ
What is the difference between the pad filter and the scale filter?
The scale filter resizes the video content itself. Pad doesn't resize anything. It adds empty space around the existing video to reach a target canvas size. You usually combine them: scale to fit, then pad to fill.
Can I add padding to only one side of the video?
Yes. Set the x and y values manually instead of centering expressions. pad=1920:1080:0:0:black puts the video in the top-left corner with all padding on the right and bottom.
Does padding increase file size significantly?
Barely. The padding area is solid color, which compresses extremely well with any modern codec. A padded video is usually only 1-3% larger than the unpadded version.
Can I pad with a transparent background?
Not in MP4 (H.264 doesn't support alpha channels). In WebM with VP9 or MOV with ProRes 4444, you can use color=0x00000000 for transparency. For most social media uses, stick with a solid color.
How do I remove existing letterbox bars from a video?
That is the opposite operation. Use cropdetect to find the bar boundaries, then crop to remove them: ffmpeg -i input.mp4 -vf "cropdetect" -f null - shows the crop values, then ffmpeg -i input.mp4 -vf "crop=W:H:X:Y" output.mp4 applies them.
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

FFmpeg Scale Filter: Resize Video and Keep Aspect Ratio
Learn how to use FFmpeg's scale filter to resize video without distortion. Covers -2 auto-scaling, force_original_aspect_ratio, pad for letterboxing, and API examples.

How to Crop and Resize Video with FFmpeg
Learn how to crop and resize video with FFmpeg using scale, crop, and pad filters. Includes CLI commands, API examples, and TikTok/Reels presets.

FFmpeg filter_complex Explained: Multi-Input Processing and Filter Chains
Learn FFmpeg filter_complex syntax for multi-input processing, filter chaining, and multi-output graphs with working code examples.
Ready to process videos at scale?
Start using FFmpeg Micro's simple API today. No infrastructure required.
Get Started Free