(with expression) - (2)¶
Watch on youtube.comSince you can pass expressions to “overlay” in ffmpeg, you can use this to make it relatively easy to make complex movements.
Though if you use all expressions explained in (ffmpeg-utils)3. Expression Evaluation, “everything can be done” within this range, here I will show you some examples that are relatively simple and likely to be used for everyday use.
00:00:00#! /bin/sh
pref="`basename $0 .sh`"
img="adult-blur-brick-wall-373918.jpg"
dur=15
#
ffmpeg -y -i "${img}" -filter_complex "
color=black:size=1920x1080,loop=loop=-1:size=2,setsar=1[bg];
[0:v]scale=-1:540,loop=loop=-1:size=2,setsar=1[iv];
[bg][iv]overlay='x=mod(t*300,(W-w)):y=(H-h)/2'[v]
" -map '[v]' -an -shortest -t ${dur} ${pref}-out.mp4
#! /bin/sh
pref="`basename $0 .sh`"
img="adult-blur-brick-wall-373918.jpg"
dur=15
#
ffmpeg -y -i "${img}" -filter_complex "
color=black:size=1920x1080,loop=loop=-1:size=2,setsar=1[bg];
[0:v]scale=-1:540,loop=loop=-1:size=2,setsar=1[iv];
[bg][iv]overlay='x=2*abs(0.5 - mod(t/10, 1))*(W-w):y=(H-h)/2'[v]
" -map '[v]' -an -shortest -t ${dur} ${pref}-out.mp4
#! /bin/sh
pref="`basename $0 .sh`"
img="adult-blur-brick-wall-373918.jpg"
dur=15
#
ffmpeg -y -i "${img}" -filter_complex "
color=black:size=1920x1080,loop=loop=-1:size=2,setsar=1[bg];
[0:v]scale=-1:540,loop=loop=-1:size=2,setsar=1[iv];
[bg][iv]overlay='x=abs(sin(t))*(W-w):y=(H-h)/2'[v]
" -map '[v]' -an -shortest -t ${dur} ${pref}-out.mp4
#! /bin/sh
pref="`basename $0 .sh`"
img="adult-blur-brick-wall-373918.jpg"
dur=15
#
ffmpeg -y -i "${img}" -filter_complex "
color=black:size=1920x1080,loop=loop=-1:size=2,setsar=1[bg];
[0:v]scale=-1:540,loop=loop=-1:size=2,setsar=1[iv];
[bg][iv]overlay='x=(1-cos(t))*(W-w)/2:y=(1-sin(t))*(H-h)/2'[v]
" -map '[v]' -an -shortest -t ${dur} ${pref}-out.mp4
#! /bin/sh
pref="`basename $0 .sh`"
img="adult-blur-brick-wall-373918.jpg"
dur=30
#
ffmpeg -y -i "${img}" -filter_complex "
color=black:size=1920x1080,loop=loop=-1:size=2,setsar=1[bg];
[0:v]scale=-1:540,loop=loop=-1:size=2,setsar=1[iv];
[bg][iv]overlay='x=(sin(t)+1)/2*(W-w):y=(cos(t/0.625)+1)/2*(H-h)'[v]
" -map '[v]' -an -shortest -t ${dur} ${pref}-out.mp4