FFMPEG filter to boxblur and greyscale a video using alpha mask

7

3

Can someone show me how to enhance the example found here: FFmpeg - Apply blur over face

To do the following:

  1. Use an input alpha mask PNG instead of a declared rectangular region
  2. both blur and greyscale the masked region

This is another example - showing how to use an alpha mask file Crop triangular area with FFMPEG

Thanks

Adam

Posted 2015-05-18T22:25:16.490

Reputation: 183

Answers

7

Here's a method using alphamerge, hue, boxblur, and overlay.

original blurred mask

Original input, filtered output, mask image.

Example:

ffmpeg -i input -loop 1 -i mask.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 output
  • The mask should be the same size as the input. If it isn't you could use scale or scale2ref to resize it.

  • The audio is stream copied to avoid unnecessary encoding.

llogan

Posted 2015-05-18T22:25:16.490

Reputation: 31 929