Blurring is an important operation in video post-production. Instead of using costly software, you can use FFmpeg’s
boxblur to blur your videos and even choose which area of the frames to blur.
In this post, let’s learn how to use FFmpeg’s
boxblur function to blur a section of a video or a part of a frame.
Anatomy of FFmpeg’s boxblur function
Before providing the full command, let’s get familiar with the baseline
There are 2 sets of coordinates mentioned here-
crop=400:400:300:350: This denotes a
400x400pixel box located
300pixels to the right and
350pixels to the bottom from the top left corner
overlay=300:350: This determines the pixels to overlay inside the box. Unless required otherwise, use the same last two coordinates mentioned in the
cropto ensure the blurred effect is applied on the pixels that are located where the box is.
10indicates the power of the blurring effect or its intensity. You can set it individually for the luma, chroma, and alpha planes and also set the blurring power. If you don’t provide the radius or the blurring power, it defaults to
With that, let’s take a look at the command to take a video input and blur a portion of it across its entire playback.
ffmpeg -i inputVideo.mp4 \ -filter_complex "[0:v]crop=200:400:300:350,boxblur=10[fg]; [0:v][fg]overlay=300:350[v]" \ -map "[v]" \ blurredVideo.mp4
Here is what the output looks like. We have a
200x400 block of pixels blurred out.
Next, let’s take a look at how to change the blurring power and what the output looks like.
FFmpeg’s boxblur with power = 10
FFmpeg’s boxblur with power = 30
Now let’s look at a blurring power =
30 to show how you can change the blurring effect using
It’s as simple as that. But that’s not all. There are a lot of fancy tricks and techniques we can use to make much more of the “boxblur”.
How to Blur all but a Specific Area of the Video using Boxblur
Let’s find out how to do the opposite of what we’ve just done, and blur everything that is not in the cropped box. Just like above,
overlay are used exactly in the same manner.
ffmpeg -i inputVideo.mp4 \ -filter_complex "[0:v]boxblur=10[bg];[0:v]crop=600:600:100:500[fg];[bg][fg]overlay=100:500" \ -map 0:v \ blurredVideo.mp4
In this article, we learned to use FFmpeg’s
boxblur function to selectively blur a portion of the video. Hope this was helpful and do check out the rest of OTTVerse’s FFmpeg tutorials.