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.mp4

How the Filtergraph Works

The -filter_complex parameter processes the video through a series of chained operations:

  1. [0:v]split=2[fg][bg]
    Duplicates the original video track into two independent video streams: [fg] (foreground) and [bg] (background).

  2. 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. The crop filter trims off any excess pixels that spill outside the target boundaries.

  3. gblur=sigma=30
    Applies a Gaussian blur to the scaled background stream. The sigma parameter determines the blur intensity; higher values result in a heavier blur, while lower values preserve more detail. A value between 20 and 40 is recommended for sidebars.

  4. [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.

  5. [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)/2 calculates the exact center coordinates for horizontal and vertical alignment.

  6. -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=30 to a higher or lower integer. You can also specify horizontal and vertical blur separately by using sigma=30:steps=2 to 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:1920 and the foreground scaling to scale=1080:-1.