6. 11. 2019

Create image slideshow with FFMPEG

Following will take all *.jpg images from current folder and create mp4 image slideshow. Images can have different sizes, ffmpeg will rescale or pad them.

ffmpeg -framerate 1/3 \
       -pattern_type glob -i '*.jpg' \
       -vf "scale=1280:720:force_original_aspect_ratio=decrease,pad=1280:720:(ow-iw)/2:(oh-ih)/2,setsar=1" \
       -c:v libx264 -crf 14 -r 25 -pix_fmt yuv422p \
       output.mp4

With background music:

ffmpeg -framerate 1/3 \
       -pattern_type glob -i '*.jpg' \
       -i audiofile.mp3 \
       -vf "scale=1280:720:force_original_aspect_ratio=decrease,pad=1280:720:(ow-iw)/2:(oh-ih)/2,setsar=1" \
       -c:v libx264 -crf 14 -r 25 -pix_fmt yuv422p \
       -shortest \
       output.mp4

#bash #ffmpeg