Create Blurred Sidebars in FFmpeg

This article demonstrates how to convert a vertical (portrait) video into a horizontal (landscape) format with blurred sidebars using a single FFmpeg command. By combining the split, scale, gblur, pad, and overlay filters, you can create a professional-looking background that mirrors and blurs the main video to fill the empty side spaces.

The FFmpeg Command

To apply this effect, run the following command in your terminal. This example converts a vertical input video into a standard 1080p (1920x1080) landscape video with blurred sidebars:

ffmpeg -i input.mp4 -filter_complex "[0:v]split=2[bg_raw][fg_raw];[bg_raw]scale=1920:1080,gblur=sigma=20[bg];[fg_raw]scale=-1:1080,pad=1920:1080:(ow-iw)/2:(oh-ih)/2:color=none[fg];[bg][fg]overlay=0:0" -c:a copy output.mp4

How the Filters Work Together

The filtergraph processes the video stream through a pipeline using five distinct filters:

  • split: This filter duplicates the incoming video stream ([0:v]) into two identical, independent streams: [bg_raw] for the background and [fg_raw] for the foreground.
  • scale (Background): The background stream [bg_raw] is scaled to the target output resolution of 1920x1080. This stretches the video to fill the entire widescreen canvas.
  • gblur: The stretched background is processed with a Gaussian blur (gblur=sigma=20). The sigma value controls the strength of the blur; higher values yield a softer background. This blurred stream is labeled [bg].
  • scale (Foreground): The foreground stream [fg_raw] is scaled to match the target height (1080) while maintaining its original aspect ratio (represented by -1).
  • pad: The scaled foreground video is placed onto a transparent virtual canvas of the final target resolution (1920:1080). The mathematical expression (ow-iw)/2 centers the video horizontally, and (oh-ih)/2 centers it vertically. The color=none parameter ensures the padded side areas remain transparent. This output is labeled [fg].
  • overlay: Finally, the padded foreground [fg] is placed directly on top of the blurred background [bg] at the top-left coordinate (0:0), completing the effect.