Image animation. Rotate

Ok, and last part – rotate image:

  • rotate cw
    ffmpeg -y -loop 1 -i bgimage.png -ss 0 -t 5 \
    -r 1 -loop 1 -i front.png -ss 0 -t 5 -filter_complex \
    " [1:v] scale=w=1920:h=1080 [fg];  \
    [0:v] scale=w='if( gt(iw, ih), -2, 2202.9071700823 )':h='if( gt(iw,ih), 2202.9071700823, -2  )', \
    rotate=a=0.39269908169872*t/5:c=black:ow=1920:oh=1080, setsar=1 [bg];  \
    [bg][fg]overlay=shortest=1[v] " \
    -map "[v]" -c:v h264 -crf 18 -preset veryfast rotate_cw.mp4
    

  • rotate ccw
    ffmpeg -y -loop 1 -i bgimage.png -ss 0 -t 5 \
    -r 1 -loop 1 -i front.png -ss 0 -t 5 -filter_complex \
    " [1:v] scale=w=1920:h=1080 [fg];  \
    [0:v] scale=w='if( gt(iw, ih), -2, 2202.9071700823 )':h='if( gt(iw,ih), 2202.9071700823, -2  )', \
    rotate=a=-0.39269908169872*t/5:c=black:ow=1920:oh=1080, setsar=1 [bg];  \
    [bg][fg]overlay=shortest=1[v] " \
    -map "[v]" -c:v h264 -crf 18 -preset veryfast rotate_ccw.mp4
    

All sources in php available on my github

Image animation. Zoom

Today we will check zoom in and out effects:

  • zoom in
    ffmpeg -y \
    -loop 1 -i bgimage.png -ss 0 -t 5 \
    -r 1 -loop 1 -i front.png -ss 0 -t 5 \
    -filter_complex " [1:v] scale=w=1920:h=1080 [fg];  \
    scale=w=-2:h=3*1080 , crop=w=3*1920:h=3*1080,  \
    zoompan=z=min(max(zoom\,pzoom)+0.0008\,1.1):d=1:x='iw/2-(iw/zoom/2)':y='ih/2-(ih/zoom/2)':s=1920x1080,  \
    setsar=1 [bg];  \
    [bg][fg]overlay=shortest=1[v] " \
    -map "[v]" -c:v h264 -crf 18 -preset veryfast zoom_in.mp4
    

  • zoom out
    ffmpeg -y -loop 1 \
    -i bgimage.png -ss 0 -t 5 \
    -r 1 -loop 1 -i front.png -ss 0 -t 5 \
    -filter_complex " [1:v] scale=w=1920:h=1080 [fg];  \
    [0:v] scale=w=-2:h=3*1080 , crop=w=3*1920:h=3*1080,  \
    zoompan=z=if(lte(zoom\,1.0)\,1/0.9\,max(1.0\,zoom+-0.0008)):d=25*5:x='iw/2-(iw/zoom/2)':\
    y='ih/2-(ih/zoom/2)':s=1920x1080,  setsar=1 [bg] ; \
    [bg][fg]overlay=shortest=1[v] " \
    -map "[v]" -c:v h264 -crf 18 -preset veryfast zoom_out.mp4
    

All sources in php available on my github

Image animation. Pan

There are several simple pan effects for image animation:

  • pan up
    ffmpeg -y -loop 1 -i bgimage.png -ss 0 -t 5 \
    -r 1 -loop 1 -i front.png -ss 0 -t 5 \
    -filter_complex " [1:v] scale=w=1920:h=1080 [fg];  \
    [0:v] scale=w=-2:h=3*1080 , crop=w=3*1920/1.2:h=3*1080/1.2:y=t*(in_h-out_h)/5,  \
    scale=w=1920:h=1080,  setsar=1 [bg] ; \
    [bg][fg]overlay=shortest=1[v] " \
    -map "[v]" -c:v h264 -crf 18 -preset veryfast pan_up.mp4
    

  • pan down
    ffmpeg -y \
    -loop 1 -i bgimage.png -ss 0 -t 5 \
    -r 1 -loop 1 -i front.png -ss 0 -t 5 \
    -filter_complex " \
    [1:v] scale=w=1920:h=1080 [fg];  \
    [0:v] scale=w=-2:h=3*1080 , crop=w=3*1920/1.2:h=3*1080/1.2:y=(in_h-out_h)-t*(in_h-out_h)/5,  \
    scale=w=1920:h=1080,  setsar=1 [bg] ;\
    [bg][fg]overlay=shortest=1[v] \
    " -map "[v]" -c:v h264 -crf 18 -preset veryfast pan_down.mp4
    

  • pan left
    ffmpeg -y -loop 1 -i bgimage.png -ss 0 -t 5 \
    -r 1 -loop 1 -i front.png -ss 0 -t 5 \
    -filter_complex " [1:v] scale=w=1920:h=1080 [fg];  \
    [0:v] scale=w=-2:h=3*1080 , crop=w=3*1920/1.05:h=3*1080/1.05:x=t*(in_w-out_w)/5,  \
    scale=w=1920:h=1080,  setsar=1 [bg] ; [bg][fg]overlay=shortest=1[v] " \
    -map "[v]" -c:v h264 -crf 18 -preset veryfast pan_left.mp4
    

  • pan right
    ffmpeg -y -loop 1 -i bgimage.png -ss 0 -t 5 \
    -r 1 -loop 1 -i front.png -ss 0 -t 5 \
    -filter_complex " [1:v] scale=w=1920:h=1080 [fg];  \
    [0:v] scale=w=-2:h=3*1080 , \
    crop=w=3*1920/1.05:h=3*1080/1.05:x=(in_w-out_w)-t*(in_w-out_w)/5,  \
    scale=w=1920:h=1080,  setsar=1 [bg] ; [bg][fg]overlay=shortest=1[v] " \
    -map "[v]" -c:v h264 -crf 18 -preset veryfast pan_right.mp4
    

All sources in php available on my github