Sunday, September 22, 2019

FFMpeg Blur Filter


Whether it be a loose Johnson, nip slip, license plate, or simply a desire to draw the viewers attention to a specific emphasis of a video a blur filter comes in handy at times.  Being able to apply a contoured filter is even better.  This post is focused on FFMpegs BoxBlur filter which does exactly that.  Let's get to it.

The filter takes in two inputs: 1) a b/w filter map, and 2) the video file.  The filter map defines the blur/unblur areas within the video frame.

Let's look at a simple rectangular blur mask;


$ ffmpeg -i clip.mp4 -loop 1 -i boxFilter.png -filter_complex "[0:v][1:v]alphamerge,hue=s=0,boxblur=5[fg]; [0:v][fg]overlay[v]" -map "[v]" -map 0:a -c:a copy output1.mp4

Results in a blurred bordered video as follows:

Similarly, we can apply a circular mask filter;

$ ffmpeg -i clip.mp4 -loop 1 -i circleFilter.png -filter_complex "[0:v][1:v]alphamerge,hue=s=0,boxblur=5[fg]; [0:v][fg]overlay[v]" -map "[v]" -map 0:a -c:a copy output0.mp4


The filter mask can be as complex as you need.

Cheers.

No comments:

Post a Comment