How to Pad a Video with an Image Using FFmpeg

Padding a video with a custom background image is a highly effective way to adapt vertical smartphone videos for widescreen displays without losing quality. This guide provides the exact FFmpeg command required to overlay your video onto a custom image background, along with a clear breakdown of how the command works so you can customize it for your projects.

To pad a video with a custom image, you will use FFmpeg’s overlay filter. This method treats the custom image as the background layer and places the video on top of it.

Here is the standard command to center a video over a background image:

ffmpeg -i background.png -i input.mp4 -filter_complex "[0:v][1:v]overlay=(W-w)/2:(H-h)/2:shortest=1[v]" -map "[v]" -map 1:a? -c:a copy output.mp4

How the Command Works