How to Pad 4:3 Video to 16:9 with FFmpeg
This guide explains how to convert a 4:3 aspect ratio video into a
16:9 widescreen format by adding black bars (pillarboxing) using
FFmpeg’s pad filter. You will learn the exact command-line
syntax, how the mathematical formula behind the filter works, and how to
scale and pad your video to a specific standard resolution like
1080p.
The Basic Pad Command
To add black bars to the left and right of a 4:3 video without altering its height or re-scaling the source, use the following FFmpeg command:
ffmpeg -i input.mp4 -vf "pad=ih*16/9:ih:(ow-iw)/2:(oh-ih)/2" -c:a copy output.mp4This command processes the video stream with the video filter
(-vf), applies the padding, and copies the audio stream
(-c:a copy) without re-encoding it to save time.
How the Pad Filter Parameters Work
The pad filter uses the syntax
pad=width:height:x:y:color. In the command above, these
variables are defined dynamically using FFmpeg’s internal constants:
ih*16/9(Output Width): Sets the output width (ow). By multiplying the input height (ih) by 16/9, FFmpeg calculates the exact width needed to achieve a 16:9 aspect ratio.ih(Output Height): Sets the output height (oh) to be equal to the input height (ih), ensuring no vertical stretching or scaling occurs.(ow-iw)/2(X-offset): Determines the horizontal placement of the input video. Subtracting the input width (iw) from the output width (ow) and dividing by 2 centers the original video, leaving equal black bars on the left and right.(oh-ih)/2(Y-offset): Determines the vertical placement. Since the output height equals the input height, this evaluates to 0, keeping the video vertically centered.- Color: By default, FFmpeg colors the padded area
black. If you want a different color, you can append it to the end of
the filter (e.g.,
pad=ih*16/9:ih:(ow-iw)/2:(oh-ih)/2:violet).
Scaling and Padding to a Specific Resolution (e.g., 1080p)
If you need the output video to fit a standard widescreen resolution,
such as Full HD (1920x1080), you must combine the scale and
pad filters in a single filterchain.
For a 4:3 video, scaling the height to 1080 pixels results in a width of 1440 pixels. You then pad the width to 1920 pixels:
ffmpeg -i input.mp4 -vf "scale=1440:1080,pad=1920:1080:(ow-iw)/2:(oh-ih)/2" -c:a copy output.mp4In this command: 1. scale=1440:1080 resizes the input
video to 1440x1080 (maintaining the 4:3 aspect ratio). 2.
pad=1920:1080:(ow-iw)/2:(oh-ih)/2 places the scaled video
inside a 1920x1080 frame and centers it, automatically generating
240-pixel-wide black bars on both the left and right sides.