geq, vignette

Watch on youtube.com
doc

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

geq

example (1)

00:00:00

This example keeps the input. That is, the converted video is the same as the input.

#! /bin/sh
ifn="Pexels_flowers_fast.mp4"
ifnb="`basename \"${ifn}\" .mp4`"
pref="`basename $0 .sh`"
#
ffmpeg -y -i "${ifn}" -vf "
geq=
lum='lum(X,Y)':
cr='cr(X,Y)':
cb='cb(X,Y)'
" -an "${pref}_${ifnb}.mp4"

example (2)

00:00:13

This example increases the luminance over time.

#! /bin/sh
ifn="Pexels_flowers_fast.mp4"
ifnb="`basename \"${ifn}\" .mp4`"
pref="`basename $0 .sh`"
#
ffmpeg -y -i "${ifn}" -vf "
geq=
lum='min(lum(X,Y) + T*7, 255)':
cr='cr(X,Y)':
cb='cb(X,Y)'
" -an "${pref}_${ifnb}.mp4"

example (3)

00:00:28

In this example, the luminance is decreased with the distance from the center. Note that this will require a lot of processing time.

#! /bin/sh
ifn="Pexels_flowers_fast.mp4"
ifnb="`basename \"${ifn}\" .mp4`"
pref="`basename $0 .sh`"
#
ffmpeg -y -i "${ifn}" -vf "
geq=
lum='max(lum(X,Y) - ((X-W/2)^2+(Y-H/2)^2)/5000., 0)':
cr='cr(X,Y)':
cb='cb(X,Y)'
" -an "${pref}_${ifnb}.mp4"

example (4)

00:00:41

This example is a slight variation of the official document example. This is a simple embossing effect. Note that this will require a lot of processing time.

#! /bin/sh
ifn="Pexels_flowers_fast.mp4"
ifnb="`basename \"${ifn}\" .mp4`"
pref="`basename $0 .sh`"
#
ffmpeg -y -i "${ifn}" -vf "
geq=
lum='(lum(X,Y)+(256-lum(X-4,Y-4)))/2':
cr='(cr(X,Y)+(256-cr(X-6,Y-6)))/2':
cb='(cb(X,Y)+(256-cb(X-8,Y-8)))/2'
" -an "${pref}_${ifnb}.mp4"

example (5)

00:00:55

This example is a slight variation of the official document example. This creates a radial gradient. Note that this will require a lot of processing time.

#! /bin/sh
ifn="Pexels_flowers_fast.mp4"
ifnb="`basename \"${ifn}\" .mp4`"
pref="`basename $0 .sh`"
#
ffmpeg -y -i "${ifn}" -vf "
geq=
'p(X,Y)*gauss((X/W-0.5)*3)*gauss((Y/H-0.5)*3)/gauss(0)/gauss(0)'
" -an "${pref}_${ifnb}.mp4"

vignette

00:01:09

As the official document does, let me show you an example of the “vignette” filter. The thing you wanted to do in the previous example is probably the territory of “vignette”. If so, this is good news for you and the processing performance is much faster than “geq”.

#! /bin/sh
ifn="Pexels_flowers_fast.mp4"
ifnb="`basename \"${ifn}\" .mp4`"
pref="`basename $0 .sh`"
#
ffmpeg -y -i "${ifn}" -vf "vignette" -an "${pref}_${ifnb}.mp4"

vignette + alphamerge

Watch on youtube.com
#! /bin/sh
ifn="Pexels_852411.mp4"
ifnb="`basename \"${ifn}\" .mp4`"
pref="`basename $0 .sh`"
#
ffmpeg -y -i "${ifn}" -filter_complex "
[0:v]scale=1280:720[0v];

color=white:s=1280x720,loop=-1:size=2,setsar=1[bg];
color=white:s=1280x720,loop=-1:size=2,setsar=1
,vignette,negate[alpha];

[bg][alpha]alphamerge[ov];

[0v][ov]overlay=shortest=1
" -an "${pref}_${ifnb}.mp4"
#! /bin/sh
ifn="Pexels_852411.mp4"
ifnb="`basename \"${ifn}\" .mp4`"
pref="`basename $0 .sh`"
#
ffmpeg -y -i "${ifn}" -filter_complex "
[0:v]scale=1280:720[0v];

color=blue:s=1280x720,loop=-1:size=2,setsar=1[bg];
color=white:s=1280x720,loop=-1:size=2,setsar=1
,vignette,negate[alpha];

[bg][alpha]alphamerge[ov];

[0v][ov]overlay=shortest=1
" -an "${pref}_${ifnb}.mp4"

See alphamerge, alphaextract.