How to Apply a Gaussian Blur to a Video with FFmpeg

Blurring a video is actually quite simple with FFmpeg, although you will need a few attempts to see what settings work best for you
by Jon Yongfook · January 2022

Contents

    Blurring a video is actually quite simple with FFmpeg, although you will need a few attempts to see what settings work best for you.

    Sometimes you may want to blur a video, for various reasons. You may want to anonymize the people in it, you may want to use it as a background etc.

    Blurring can be achieved natively in FFmpeg via a simple command.

    What is a Gaussian Blur?

    A blur is not just a blur.

    You can blur an image using different calculations / formulas and the results will be slightly different. The most common types of blur are radial blur, box blur, variable blur and gaussian blur.

    A gaussian blur is a particular type of blur. It is a type of blur effect that uses a Gaussian function for calculating the transformation to apply to each pixel in the image.

    Can FFmpeg do guassian blurs?

    Yes, FFmpeg supports two types of blur effects - box blur and gaussian blur. We will take a look at both in this article.

    Baseline video

    Here is the video we will be applying blur effects to:

    Applying a mild box blur effect

    ffmpeg -i man.mp4 -vf "boxblur=10" -c:a copy man-blur.mp4

    Applying a strong box blur effect

    Increasing the number of the boxblur filter increases the radius of the blur.

    ffmpeg -i man.mp4 -vf "boxblur=50" -c:a copy man-blur-more.mp4

    Applying a very strong box blur effect

    You can increase the intensity of the blur with a second parameter, below uses a radius value of 50 that is then applied 5 times resulting in a very strong blur effect.

    ffmpeg -i man.mp4 -vf "boxblur=50:5" -c:a copy man-blur-more-more.mp4

    Now lets use the same parameters on the gaussian blur effect filter gblur.

    Applying a mild gaussian blur effect

    In FFmpeg the gblur filter takes 2 parameters, the standard deviation and the number of steps for gaussian approximation. Standard deviation will range from 0.5 upwards while steps can be a number from 1 to 6.

    ffmpeg -i man.mp4 -vf "gblur=sigma=10" -c:a copy man-gblur.mp4

    Applying a strong gaussian blur effect

    ffmpeg -i man.mp4 -vf "gblur=sigma=50" -c:a copy man-gblur-more.mp4

    Applying a very strong gaussian blur effect

    As with the box blur you can increase the intensity of the blur with a second parameter, below uses a sigma value of 50 that is then applied 5 times resulting in a very strong blur effect.

    ffmpeg -i man.mp4 -vf "gblur=sigma=50:steps=5" -c:a copy man-gblur-more-more.mp4

    Which blur should you use?

    In the end the decision is mostly an aesthetic one. The best way of thinking about the visual difference between a box blur and a gaussian blur is that a box blur gets you an effect similar to the bokeh effect of an SLR camera. A gaussian blur on the other hand, is more like a "frosted glass" effect.

    Use the Bannerbear Video API

    If you need to perform these kinds of FFmpeg operations in the cloud, you can try using the Bannerbear Video API which simplifies this FFmpeg command line experience and makes it more developer-friendly for performing common tasks like blurring videos, joining video clips, turning images into slideshows and more.

    About the authorJon Yongfook@yongfook
    Jon is the founder of Bannerbear. He has worked as a designer and programmer for 20 years and is fascinated by the role of technology in design automation.

    How to Use the Bannerbear WordPress Plugin to Generate Dynamic Open Graph Images

    The Bannerbear WordPress Plugin is here! Learn how to add the plugin to WordPress and set up a Signed URL to create custom images automatically for your website.

    Top 5 Automated UI Testing Tools to Make Testing Faster in 2022

    Speed is key in 2022, test and ship fast. These five tools will get your tests running faster than ever. Find out more about how they can help to make sure your application functions as expected in this article.

    How to Build a Video Thumbnail Generator Tool Using React and Bannerbear

    Improve users' workflow by integrating a video thumbnail generator that adds text to an image uploaded by them using Bannerbear API.

    Follow the Journey

    Sign up for our once a fortnight newsletter update on new Bannerbear features and our business journey

    How to Apply a Gaussian Blur to a Video with FFmpeg
    How to Apply a Gaussian Blur to a Video with FFmpeg