FFmpeg Blurred Sidebars Using gblur Filter
This guide demonstrates how to convert videos with mismatched aspect
ratios—such as a vertical smartphone recording displayed on a widescreen
display—into a professional 16:9 presentation using FFmpeg. By splitting
the video into two streams, scaling and blurring the background stream
using the gblur (Gaussian blur) filter, and centering the
original sharp video on top, you can eliminate black pillarbox bars and
replace them with dynamic, blurred sidebars.
The Complete FFmpeg Command
To apply blurred sidebars to an input video, run the following command in your terminal:
ffmpeg -i input.mp4 -filter_complex "[0:v]split=2[fg][bg]; [bg]scale=1920:1080:force_original_aspect_ratio=increase,crop=1920:1080,gblur=sigma=30[blurred]; [fg]scale=-1:1080[main]; [blurred][main]overlay=(W-w)/2:(H-h)/2" -c:a copy output.mp4How the Filtergraph Works
The -filter_complex parameter processes the video
through a series of chained operations:
[0:v]split=2[fg][bg]
Duplicates the original video track into two independent video streams:[fg](foreground) and[bg](background).scale=1920:1080:force_original_aspect_ratio=increase,crop=1920:1080
Resizes the background stream so that it completely fills the target 1920x1080 resolution without distorting the aspect ratio. Thecropfilter trims off any excess pixels that spill outside the target boundaries.gblur=sigma=30
Applies a Gaussian blur to the scaled background stream. Thesigmaparameter determines the blur intensity; higher values result in a heavier blur, while lower values preserve more detail. A value between20and40is recommended for sidebars.[fg]scale=-1:1080[main]
Scales the foreground video to fit within the 1080-pixel height limit while automatically calculating the width (-1) to preserve its original aspect ratio.[blurred][main]overlay=(W-w)/2:(H-h)/2
Places the sharp foreground stream ([main]) over the center of the blurred background stream ([blurred]). The formula(W-w)/2:(H-h)/2calculates the exact center coordinates for horizontal and vertical alignment.-c:a copy
Copies the audio stream directly from the input without re-encoding, preserving original audio quality and saving processing time.
Customization Options
- Adjust Blur Strength: Change
sigma=30to a higher or lower integer. You can also specify horizontal and vertical blur separately by usingsigma=30:steps=2to adjust blur smoothness and quality. - Target Resolution: To produce a vertical video
(e.g., 1080x1920 for platforms like TikTok or YouTube Shorts) from a
widescreen source, change the resolution values in the background to
scale=1080:1920:force_original_aspect_ratio=increase,crop=1080:1920and the foreground scaling toscale=1080:-1.