floodfill

Watch on youtube.com
doc

https://ffmpeg.org/ffmpeg-filters.html#floodfill, https://ffmpeg.org/ffmpeg-filters.html#geq

Example 1

00:00:00

In this example, firstly, as a preprocessing, a sufficiently dark area is replaced with strict black by “geq” filter. Then all the black surrounding the position (0, 0) is replaced with blue.

#! /bin/sh
ifn="Pexels_4614-1080p-slow-25fps.mp4"
ifnb="`basename \"${ifn}\" .mp4`"
pref="`basename $0 .sh`"
#
"/c/Program Files/ffmpeg-4.1-win64-shared/bin/ffmpeg" -y \
-i "${ifn}" -filter_complex "
[0:v]
format=rgb24,

geq='
r=if(lte(r(X,Y),16),0,r(X,Y)):
g=if(lte(g(X,Y),16),0,g(X,Y)):
b=if(lte(b(X,Y),16),0,b(X,Y))',

floodfill=
x=0:y=0:
s0=0:s1=0:s2=0:
d0=0:d1=255:d2=0
[v]" -map '[v]' -an "${pref}_${ifnb}.mp4"

The document does not explain exactly one thing, apparently it seems that plane 0 is G (Green), 1 is B (blue), 2 is R (Red).

Example 2

00:00:18

In this example, firstly, as a preprocessing, a sufficiently dark area is replaced with strict black by “geq” filter. Then all the black surrounding the position (10, 1070) is replaced with green.

#! /bin/sh
ifn="Pexels_3456-1080p-slow-25fps.mp4"
ifnb="`basename \"${ifn}\" .mp4`"
pref="`basename $0 .sh`"
#
"/c/Program Files/ffmpeg-4.1-win64-shared/bin/ffmpeg" -y \
-i "${ifn}" -filter_complex "
[0:v]
format=rgb24,

geq='
r=if(lte(r(X,Y),48),0,r(X,Y)):
g=if(lte(g(X,Y),48),0,g(X,Y)):
b=if(lte(b(X,Y),48),0,b(X,Y))',

floodfill=
x=10:y=1070:
s0=0:s1=0:s2=0:
d0=255:d1=0:d2=0
[v]" -map '[v]' -an "${pref}_${ifnb}.mp4"