Blur following object movement¶
`delogo’ with option `enable’¶
The purpose of `delogo’ is not “blurring”. However, unlike other specialized “blur” filters, because it is possible to specify a target area and “enable” can be used, so it is the most convenient way for “blur following object movement”:
#! /bin/sh
pref="`basename $0 .sh`"
ifn="Pexels Videos 1601540.mp4"
#
ffmpeg -y -i "${ifn}" -filter_complex "
[0:v]
delogo='x=20:y=700:w=500:h=320:show=1:enable=between(t, 0, 2)'
,delogo='x=20+400:y=700:w=500:h=320:show=1:enable=between(t, 2, 4)'
,delogo='x=20+400*2:y=700:w=500:h=320:show=1:enable=between(t, 4, 6)'
,delogo='x=20+400*3:y=700:w=500:h=320:show=1:enable=between(t, 6, 8)'
,delogo='x=20:y=700:w=500:h=320:show=1:enable=between(t, 8, 10)'
,delogo='x=20+400:y=700:w=500:h=320:show=1:enable=between(t, 10, 12)'
,delogo='x=20+400*2:y=700:w=500:h=320:show=1:enable=between(t, 12, 14)'
,delogo='x=20+400*3:y=700:w=500:h=320:show=1:enable=between(t, 14, 16)'
,delogo='x=20:y=700:w=500:h=320:show=1:enable=between(t, 16, 18)'
,delogo='x=20+400:y=700:w=500:h=320:show=1:enable=between(t, 18, 20)'
,delogo='x=20+400*2:y=700:w=500:h=320:show=1:enable=between(t, 20, 22)'
" -an "${pref}.mp4"
Otherwise¶
- see also
crop, then blur, and overlay¶
Unlike “delogo”, professional blur filters like “avgblur” do not allow you to specify the target area. Therefore, in order to follow the object movement while blurring the partial area, for example it is realized by combining with “crop” and “overlay”:
#! /bin/sh
pref="`basename $0 .sh`"
ifn="Pexels Videos 1601540.mp4"
#
xexpr="\
between(t, 0, 2 - 0.01) * (20)
+ between(t, 2, 4 - 0.01) * (20 + 400)
+ between(t, 4, 6 - 0.01) * (20 + 400*2)
+ between(t, 6, 8 - 0.01) * (20 + 400*3)
+ between(t, 8, 10 - 0.01) * (20)
+ between(t, 10, 12 - 0.01) * (20 + 400)
+ between(t, 12, 14 - 0.01) * (20 + 400*2)
+ between(t, 14, 16 - 0.01) * (20 + 400*3)
+ between(t, 16, 18 - 0.01) * (20)
+ between(t, 18, 20 - 0.01) * (20 + 400)
+ between(t, 20, 22 - 0.01) * (20 + 400*2)"
#
ffmpeg -y -i "${ifn}" -filter_complex "
[0:v]split[0v1][0v2];
[0v1]
crop='
w=500:h=320:
x=${xexpr}:
y=700'
,setsar=1
,avgblur=40
,drawbox=c=blue[b];
[0v2][b]
overlay='
x=${xexpr}:
y=700'
" -an "${pref}.mp4"
#! /bin/sh
pref="`basename $0 .sh`"
ifn="Pexels Videos 1601540.mp4"
#
xexpr="mod(20 + (t/2)*400, 1920 - 500)"
#
ffmpeg -y -i "${ifn}" -filter_complex "
[0:v]split[0v1][0v2];
[0v1]
crop='
w=500:h=320:
x=${xexpr}:
y=700'
,setsar=1
,boxblur=lr=10:lp=4
,drawbox=c=blue[b];
[0v2][b]
overlay='
x=${xexpr}:
y=700'
" -an "${pref}.mp4"
If the purpose of your “blur” is to make it difficult to identify the object¶
- see also
If the purpose of your “blur” is to make it difficult to identify the object and if you want an interesting visual effect, it is not necessary to stick to “only professional blur filters”…
#! /bin/sh
pref="`basename $0 .sh`"
ifn="Pexels Videos 1601540.mp4"
#
gridsize=${gridsize:-32}
#
xexpr="mod(20 + (t/2)*400, 1920 - 500)"
#
ffmpeg -y -i "${ifn}" -filter_complex "
color=0x99FF99@0.9:s=500x320:d=20.57[b];
[0:v][b]overlay='x=${xexpr}:y=700'
" -an "${pref}.mp4"
#! /bin/sh
pref="`basename $0 .sh`"
ifn="Pexels Videos 1601540.mp4"
#
gridsize=${gridsize:-32}
#
xexpr="mod(20 + (t/2)*400, 1920 - 500)"
#
ffmpeg -y -i "${ifn}" -filter_complex "
[0:v]split=3[0v1][0v2][0v3];
[0v1]crop='w=500:h=320:x=${xexpr}:y=700'
,avgblur=10
,geq='lum=lum(X,Y)*(1+(1.5-(mod(floor(T*2),2)+1))/10)
:cr=cr(X,Y):cb=cb(X,Y)',setsar=1[d1];
[0v2]crop='w=500:h=320:x=${xexpr}:y=700'
,avgblur=10
,geq='lum=lum(X,Y)*(1-(1.5-(mod(floor(T*2),2)+1))/10)
:cr=cr(X,Y):cb=cb(X,Y)',setsar=1[d2];
[d1][d2]blend=all_expr='
if(eq(mod(floor(X/${gridsize}),2),mod(floor(Y/${gridsize}),2)),A,B)'
[b];
[0v3][b]overlay='x=${xexpr}:y=700'
" -an "${pref}.mp4"