FFmpeg Pad Video with Transparent Borders

This article explains how to use FFmpeg to add transparent borders to a video using the video padding filter. You will learn the exact command syntax, how to configure the padding dimensions, how to define the transparent background color, and which output formats to use to properly preserve the alpha channel transparency.

To pad a video with transparent borders, you must use the pad filter, specify a transparent color, and export the file using a video codec that supports an alpha channel (transparency). Standard formats like H.264 MP4 do not support transparency, so you must use formats like WebM (VP9) or QuickTime (MOV).

The FFmpeg Command

Here is the standard command to add a transparent border to a video and export it as a WebM file:

ffmpeg -i input.mp4 -vf "pad=iw+100:ih+100:50:50:color=black@0,format=yuva420p" -c:v libvpx-vp9 output.webm

Command Breakdown

Alternative: Exporting to QuickTime MOV (ProRes)

If you need a high-quality intermediate file for video editing software like Adobe Premiere or DaVinci Resolve, you should output to a QuickTime .mov file using the ProRes codec:

ffmpeg -i input.mp4 -vf "pad=iw+120:ih+120:60:60:color=black@0,format=yuva444p10le" -c:v prores_ks -profile:v 4 output.mov

Centering the Video Automatically

If you want to pad a video to a specific resolution (for example, placing a 1280x720 video inside a 1920x1080 canvas) and keep the video perfectly centered, use mathematical expressions for the offset:

ffmpeg -i input.mp4 -vf "pad=1920:1080:(ow-iw)/2:(oh-ih)/2:color=black@0,format=yuva420p" -c:v libvpx-vp9 output.webm