Add black letterbox or pillarbox bars to fit a different aspect ratio
The pad filter adds padding (usually black) around the video to fit a target aspect ratio. The classic use is letterboxing 4:3 content into a 16:9 frame for delivery, or pillarboxing 16:9 into a 4:3 frame for an older player. The output is the same video centered with black bars on the missing area.
The command
ffmpeg -i input.mp4 -vf "pad=1920:1080:(1920-iw)/2:(1080-ih)/2:black" output.mp4What it does
FFmpeg pads each frame to 1920x1080, placing the original video centered. The expression (1920-iw)/2 computes the horizontal offset to center the video: the difference between the target width and the input width, divided by two. The :black is the fill color.
When to use it
For fitting a 4:3 source into a 16:9 delivery, or for adding letterbox bars to a 2.39:1 film so it displays correctly on a 16:9 player without cropping. Pillarbox (vertical bars) is the same filter with the expressions swapped; both are 16:9-to-X aspect conversion.
Video and audio requirements
Any decodable video. The output dimensions must be large enough to contain the source. pad=1920:1080 pads a source smaller than 1920x1080; for sources already 1920x1080, the filter is a no-op. Audio is unaffected.
Things to avoid
- Using
padto fake an aspect ratio change without changing the SAR. The result plays with the new pixel dimensions but the same display aspect as the source. Set the SAR explicitly withsetdar=16/9if the deliverable expects a 16:9 frame. - Forgetting that
:blackcan be any color.:0x808080for gray,:redfor red, or a pixel value. For a transparent pad, use a non-standard pixel format likeyuva420pand:0x00000000. - Combining with scale in the wrong order.
scale, padscales first, then pads; the pad is the larger size.pad, scalepads first, then scales; the scale might shrink the padded frame. Usuallyscale, padis what you want. - Using
padfor anamorphic sources. An anamorphic source has non-square pixels and should be corrected withsetdar, not padded. Padding an anamorphic source produces a stretched or squeezed image.