FFmpeg examples using image fade in and out of video. How to zoom in a video,
sliding an image across a video and overlaying a spining image to a video.
Fade an image into a video starting at ten seconds take 2 seconds to complete.
Fade out at 20 seconds take 3 seconds to completely fade out.
EXAMPLE
ffmpeg -i vids/short.mp4 -loop 1 -i small.png -filter_complex \ "[1:v]fade=t=in:st=10:d=2,fade=t=out:st=20:d=3[over];[0:v][over]overlay=50:50" \ -pix_fmt yuv420p -c:a copy -t 30 vids/VIDEO.mp4
Zoom in a video
Zoom 1.5 ( zoom,1.5 ) times over period of 700 ( d=700 )
ffmpeg -i vids/short.mp4 \ -vf "zoompan=z='zoom+0.001':x='if(gte(zoom,1.5),x,x-1)':y='y':d=700" \ -c:a copy -t 30 vids/ZOOM.mp4 ffmpeg -r 25 -i LVjYi.jpg -filter_complex \ "scale=-2:10*ih,zoompan=z='min(zoom+0.0015,1.5)':d=125:x='iw/2-(iw/zoom/2)':y='ih/2-(ih/zoom/2)',scale=-2:720" \ -y -shortest -c:v libx264 image_output.mp4 ffmpeg -i $1 -vf "zoompan=z='min(zoom+0.01,2.5)':x='iw/2-iw*(1/2-27/100)*on/150-iw/zoom/2':y='ih/2-ih*(1/2-81/100)*on/150-ih/zoom/2':d=150,scale=720:720" \ -c:v libx264 -y $2
Simple Overlay Without Sound
ffmpeg -i vids/ZOOM.mp4 -i small.png -filter_complex \ 'overlay[out]' -map '[out]' vids/zoom-small.mp4
Simple Sliding Overlay Without Sound ( The black and white words is the image )
Slide an image across a video - start after 5 seconds end at 20 seconds.
between=(t,5,20)
ffmpeg -i vids/short.mp4 -i small.png -filter_complex \ "[0:v][1:v]overlay=enable='between=(t,5,20)':x=120+t*28:y=t*10[out]" \ -map "[out]" vids/imageslide.mp4
Sliding a Text Image From Right to Left ( The image is below )
Slide the text image across a video - start after 3 seconds end at 30 seconds.
between=(t,3,30)
Start location 1220 (x=1220) with each step of t move left 60px (x=1220-t*60).
Set y axis at 50px (y=50[out])
ffmpeg -i vids/short.mp4 -i scrolling-text.png -filter_complex \ "[0:v][1:v]overlay=enable='between=(t,3,30)':x=1220-t*60:y=50[out]" \ -map "[out]" vids/imagescroll.mp4
Spin an Overlay On a Video ( The image is below )
Crteate an increasing t variable
overlay=enable='between=(t,30,31)
between=(t,3,30)
Start location 1220 (x=1220) with each step of t move left 60px (x=1220-t*60).
Set y axis at 50px (y=50[out])
NOTE : iw : input width ih : input height ffmpeg -i vids/short.mp4 -i arrow.png -filter_complex \ "[1:v]overlay=enable='between=(t,30,31)', \ rotate=30*PI*t/180:c=none:ow=rotw(iw):oh=roth(ih), \ scale=300:-1[rotate];[0:v][rotate] overlay=640:360[out]" \ -map [out] -t 29 vids/spin5a.mp4
ffmpeg -i vids/short.mp4 -i small.png -filter_complex "[1:v]overlay=enable='between=(t,30,31)', rotate=30*PI*t/180:c=none:ow=rotw(iw):oh=roth(ih), scale=300:-1[rotate];[0:v][rotate] overlay=640:360[out]" -map [out] -t 29 spin5a.mp4 ffmpeg -i vids/short.mp4 -i small.png -filter_complex "[1:v]overlay=enable='between=(t,30,30)', rotate=30*PI*t/180:c=none:ow=rotw(iw):oh=roth(ih),scale=300:-1[rotate];[0:v][rotate] overlay=640:360[out]" -map [out] -t 29 spin5.mp4 ffmpeg -i vids/short.mp4 -i small.png -filter_complex \ "[1:v]overlay=enable='between=(t,3,10)' rotate=30*PI/180:c=none:ow=rotw(iw):oh=roth(ih),scale=300:-1[rotate];[0:v][rotate] \ overlay=40:10[out]" -map [out] spin.mp4 ffmpeg -i vids/short.mp4 -i small.png -filter_complex "[1:v]overlay=enable='between=(t,3,30)', rotate=30*PI*t/180:c=none:ow=rotw(iw):oh=roth(ih),scale=300:-1[rotate];[0:v][rotate] overlay=40:10[out]" -map [out] spin3.mp4 ffmpeg -i vids/short.mp4 -i small.png -filter_complex "[0:v][1:v]overlay=enable='between=(t,3,30)', rotate=30*PI*t/180:c=none:ow=rotw(iw):oh=roth(ih),scale=300:-1[rotate];[0:v][rotate] overlay=40:10[out]" -map [out] spin4.mp4