(with expression) - (1) scroll, roll¶
- see also
ffmpeg does not provide a direct way to scroll¶
Watch on youtube.comNote
From version 4.3, you can use scroll filter.
ffmpeg does not provide a direct way to scroll, but you can use “overlay” instead.
00:00:00#! /bin/sh
pref="`basename $0 .sh`"
img="adorable-animal-cat-730896.jpg"
dur=15
#
ffmpeg -y -i "${img}" -filter_complex "
color=skyblue:size=1920x1080,loop=loop=-1:size=2,setsar=1[bg];
[0:v]scale=1920:-1,loop=loop=-1:size=2,setsar=1[iv];
[bg][iv]overlay='x=-t/${dur}*w'[v]
" -map '[v]' -an -shortest -t ${dur} ${pref}-out.mp4
#! /bin/sh
pref="`basename $0 .sh`"
img="adorable-animal-cat-730896.jpg"
dur=15
#
ffmpeg -y -i "${img}" -filter_complex "
color=skyblue:size=1920x1080,loop=loop=-1:size=2,setsar=1[bg];
[0:v]hflip,scale=1920:-1,loop=loop=-1:size=2,setsar=1[iv];
[bg][iv]overlay='x=-t/${dur}*w',hflip[v]
" -map '[v]' -an -shortest -t ${dur} ${pref}-out.mp4
#! /bin/sh
pref="`basename $0 .sh`"
img="adorable-animal-cat-730896.jpg"
dur=15
#
ffmpeg -y -i "${img}" -filter_complex "
color=black:size=1920x1080,loop=loop=-1:size=2,setsar=1[bg];
[0:v]scale=1920:-1,loop=loop=-1:size=2,setsar=1[fg1];
[0:v]scale=1920:-1,loop=loop=-1:size=2,setsar=1[fg2];
[bg][fg1]overlay='x=-t/${dur}*w'[vb];
[vb][fg2]overlay='x=W-t/${dur}*w'[v]
" -map '[v]' -an -shortest -t ${dur} ${pref}-out.mp4
#! /bin/sh
pref="`basename $0 .sh`"
img="adorable-animal-cat-730896.jpg"
dur=15
#
ffmpeg -y -i "${img}" -filter_complex "
color=black:size=1920x1080,loop=loop=-1:size=2,setsar=1[bg];
[0:v]hflip,scale=1920:-1,loop=loop=-1:size=2,setsar=1[fg1];
[0:v]hflip,scale=1920:-1,loop=loop=-1:size=2,setsar=1[fg2];
[bg][fg1]overlay='x=-t/${dur}*w'[vb];
[vb][fg2]overlay='x=W-t/${dur}*w',hflip[v]
" -map '[v]' -an -shortest -t ${dur} ${pref}-out.mp4
Slideshow-like, or paging¶
To achieve a “slideshow-like” effect, if you allow pre-combining of the images, you can do it like this:
Watch on youtube.com00:00:00#! /bin/bash
pref="`basename $0 .sh`"
#
ifn="shading_example.png" # Image obtained by combining 34 images horizontally
#
t="t"
images=34
pause=7
wipe=1
perpage=$((${pause} + ${wipe}))
#
ffmpeg -y -i "${ifn}" -filter_complex "
color=white:s=1920x1080,loop=-1:size=2[bg];
[0:v]scale='1920*${images}:1080',loop=-1:size=2[0v];
[bg][0v]overlay='
x=-1920*if(
gte(mod(${t}, ${perpage}), ${pause}),
floor(${t} / ${perpage}) + (mod(${t}, ${perpage}) - ${pause}),
floor(${t} / ${perpage}))
'
" -t $((${perpage} * ${images} - ${wipe})) ${pref}.mp4
#! /bin/bash
pref="`basename $0 .sh`"
#
ifn="cal_2019_2020.png" # Image obtained by combining 24 images vertically
#
t="t"
images=24
pause=7
wipe=1
perpage=$((${pause} + ${wipe}))
#
ffmpeg -y -i "${ifn}" -filter_complex "
color=white:s=1920x1080,loop=-1:size=2[bg];
[0:v]scale='1920:1080*${images}',loop=-1:size=2[0v];
[bg][0v]overlay='
y=-1080*if(
gte(mod(${t}, ${perpage}), ${pause}),
floor(${t} / ${perpage}) + (mod(${t}, ${perpage}) - ${pause}),
floor(${t} / ${perpage}))
'
" -t $((${perpage} * ${images} - ${wipe})) ${pref}.mp4
It should be noted that this is not the only way to get a slideshow effect. In some cases, pre-combining may not be acceptable because of the size of the image.