I'm using ffmpeg to create a vertical video of zoomming a horizontal (landscape) photo.
I want the photo to fit the width of the video, so the top and bottom of the photo need to fill the empty space with the blurry photo:
The script image_to_video_zoom_vertical.sh
to zoom a horizontal photo in a vertical video and fill the empty space at the top and bottom with a blurry photo using ffmpeg:
INPUT="$1"
OUTPUT="${INPUT%%.*}_zoom.MP4"
MAX_ZOOM="${2:-1.2}"
DURATION_SECONDS="${3:-5}"
FPS="30"
DURATION=$(bc <<< "${DURATION_SECONDS}*${FPS}")
ZOOM_SPEED=$(bc <<< "scale=4;(${MAX_ZOOM}-1)/${DURATION}")
W=1080
H=1920
ffmpeg -i "$INPUT" \
-filter_complex "[0]scale=w=-1:h=${H},boxblur=50[bg];[0]format=rgba,pad=w=iw:h=iw*${H}/${W}:x=(ow-iw)/2:y=(oh-ih)/2:color=#00000000,zoompan=z='zoom+${ZOOM_SPEED}':x='iw/2-iw/zoom/2':y='ih/2-ih/zoom/2':d=${DURATION}:fps=${FPS}:s=${W}x${H}[fg];[bg][fg]overlay=(W-w)/2:(H-h)/2,crop=${W}:${H}" \
-pix_fmt yuv420p -c:v libx264 "$OUTPUT" -y