Pad Vertical Video with Blurred Background in FFmpeg
This article explains how to convert a vertical (9:16) video into a
horizontal (16:9) video by padding the empty sides with a blurred,
scaled-up version of the original footage. Using a single FFmpeg complex
filtergraph (-filter_complex), you can duplicate the video
stream, apply scaling and blurring filters to one stream to create the
background, and overlay the original vertical video centered on top of
it.
The FFmpeg Command
To pad a vertical video (such as a smartphone recording) to a standard landscape 1080p resolution (1920x1080) with a blurred background, run the following command in your terminal:
ffmpeg -i input.mp4 -filter_complex "[0:v]split=2[bg][fg];[bg]scale=1920:1080,boxblur=40:20[blurred];[fg]scale=-1:1080[foreground];[blurred][foreground]overlay=(W-w)/2:(H-h)/2" -c:a copy output.mp4How the Filtergraph Works
The -filter_complex flag allows you to link multiple
filters together. Here is a breakdown of how the filter chain processes
the video:
[0:v]split=2[bg][fg]This splits the input video stream ([0:v]) into two identical, independent streams labeled[bg](background) and[fg](foreground).[bg]scale=1920:1080,boxblur=40:20[blurred]scale=1920:1080: Scales the background stream to fill a standard 1080p landscape frame.boxblur=40:20: Applies a strong blur effect to the background video. The first number (40) is the blur radius, and the second number (20) is the power (how many times the blur filter is applied). You can increase or decrease these values to change the intensity of the blur.- The resulting processed stream is labeled
[blurred].
[fg]scale=-1:1080[foreground]This scales the foreground video to match the height of the output frame (1080pixels) while setting the width to-1, which forces FFmpeg to automatically calculate the correct width to preserve the video’s original vertical aspect ratio. This stream is labeled[foreground].[blurred][foreground]overlay=(W-w)/2:(H-h)/2This overlays the[foreground]stream on top of the[blurred]background.WandHrepresent the width and height of the background video (1920x1080).wandhrepresent the width and height of the foreground vertical video.(W-w)/2:(H-h)/2mathematically centers the vertical video horizontally and vertically on top of the blurred background.
Adjusting the Output Resolution
If you want to output a different resolution, such as 720p (1280x720) or 4K (3840x2160), simply change the scaling values in the command.
For 720p:
ffmpeg -i input.mp4 -filter_complex "[0:v]split=2[bg][fg];[bg]scale=1280:720,boxblur=40:20[blurred];[fg]scale=-1:720[foreground];[blurred][foreground]overlay=(W-w)/2:(H-h)/2" -c:a copy output.mp4