fftfilt

Watch on youtube.com
doc

https://ffmpeg.org/ffmpeg-filters.html#fftfilt

Just like “convolution” you can also use the generic filter “fftfilt” for blurring purposes.

As the name suggests, this filter allows you to apply arbitrary expressions to samples in frequency domain.

As with “convolution”, understanding and familiarity with mathematics or image processing is also necessary for use of this, I personally think that thinking in the frequency domain is intuitive, so blurring control by this filter may be easier than “convolution”. Even so, of course, easiness to understand of dedicated blur filters is much larger than this filter. If you can not understand the way of thinking in the frequency domain, use “avgblur” etc. obediently.

Example 1

00:00:45

This example is the same as that in the official document. Only the luminance component is processed. (Since humans are sensitive to luminance components, in most cases, it is the idea that only processing luminance components suffices.)

#! /bin/sh
ifn="Pexels_flowers.mp4"
ifnb="`basename \"${ifn}\" .mp4`"
pref="`basename $0 .sh`"
#
ffmpeg -y -i "${ifn}" -filter_complex "
[0:v]
crop=600:400:960:540,setsar=1,
fftfilt=dc_Y=0:weight_Y='exp(-4 * ((Y+X)/(W+H)))'

,drawbox=c=blue
[blurring];

[0:v][blurring]overlay=960:540[v]
" -map '[v]' -an "${pref}_${ifnb}.mp4"

Example 2

00:01:15

It is a slightly changed calculation of the previous example.

#! /bin/sh
ifn="Pexels_flowers.mp4"
ifnb="`basename \"${ifn}\" .mp4`"
pref="`basename $0 .sh`"
#
ffmpeg -y -i "${ifn}" -filter_complex "
[0:v]
crop=600:400:960:540,setsar=1,
fftfilt=dc_Y=0:weight_Y='exp(-16 * ((Y+X)/(W+H)))'

,drawbox=c=blue
[blurring];

[0:v][blurring]overlay=960:540[v]
" -map '[v]' -an "${pref}_${ifnb}.mp4"

Example 3

00:01:45

Normally it’s not worth doing this, but if you apply the same expression for U and V planes it will be like this.

#! /bin/sh
ifn="Pexels_flowers.mp4"
ifnb="`basename \"${ifn}\" .mp4`"
pref="`basename $0 .sh`"
#
ffmpeg -y -i "${ifn}" -filter_complex "
[0:v]
crop=600:400:960:540,setsar=1,
fftfilt=
dc_Y=0:weight_Y='exp(-4 * ((Y+X)/(W+H)))':
dc_U=0:weight_U='exp(-4 * ((Y+X)/(W+H)))':
dc_V=0:weight_V='exp(-4 * ((Y+X)/(W+H)))'

,drawbox=c=blue
[blurring];

[0:v][blurring]overlay=960:540[v]
" -map '[v]' -an "${pref}_${ifnb}.mp4"