Skip to content

Instantly share code, notes, and snippets.

@Enweave
Last active March 31, 2020 12:42
Show Gist options
  • Select an option

  • Save Enweave/8ec5c34481caf1aaa25e11d1f96540b7 to your computer and use it in GitHub Desktop.

Select an option

Save Enweave/8ec5c34481caf1aaa25e11d1f96540b7 to your computer and use it in GitHub Desktop.
ffmpeg create looped slideshow over a music track.
#!/bin/bash
# folder wth images
IMAGE_DIRECTORY="test_footage"
# image extension
IMAGE_EXT="jpg"
#SLIDE TIME IN SECONDS
SLIDE_DURATION=2
#audio track file
AUDIO="test_footage/music.mp3"
#output file
LOOP_FILE="loop.mp4"
OUT="out.mp4"
FR=$(awk "BEGIN {print 1/$SLIDE_DURATION}")
ffmpeg -y -framerate $FR -pattern_type glob -i "$IMAGE_DIRECTORY/*.$IMAGE_EXT" -vf "pad=ceil(iw/2)*2:ceil(ih/2)*2" -q:v 2 $LOOP_FILE
ffmpeg -stream_loop -1 -i $LOOP_FILE -c copy -v 0 -f nut - | ffmpeg -y -thread_queue_size 10K -i - -i $AUDIO -c copy -map 0:v -map 1:a -shortest $OUT
rm $LOOP_FILE
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment