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

Leave a Reply

Your email address will not be published. Required fields are marked *