3

I see this page on how to do this with images numerically. But I have a directory of images that look like this for example:

ADAM SANDLER.jpg
JOHN DOE.jpg
SAM SMITH.jpg

I want to create a video slideshow from all of the images in this directory, sorted alphabetically.

Is there any way to do this?

EDIT

In the end, I'm trying to create a vertical video to post on Instagram. These photos are portraits so it will need to be a "vertical" video. It seems FFMPEG is having issues with this, at least playing the video in Quicktime doesn't seem to be working. It needs to be a 15 second video, and there are 25 images.

This is the command I'm running, and it's just appearing black when I open it in Quicktime. When I open in VLC it's playing but only shows the first couple frames.

ffmpeg -r 1 -i img%03d.jpg -c:v libx264 -pix_fmt yuv420p out.mp4

2 Answers 2

6

You can use the concat demuxer.

First, prepare a text file containing the list of all images in the order you want. In Windows, from a command prompt, you can run this command, in the folder:

dir *.jpg /b /on > list.txt

Now prefix each line with file ' and suffix with ', so that each line looks like

file 'ADAM SANDLER.jpg'

you may want to duplicate the last line due to a bug in the fps filter.

Now, if all your images are of the same size, run

ffmpeg -f concat -r 1/2 -i list.txt -crf 20 -vf fps=8,format=yuv420p video.mp4

If not, and assuming 1920x1080 as output video size, run

ffmpeg -f concat -r 1/2 -i list.txt -vf "scale=iw*min(1920/iw\,1080/ih):ih*min(1920/iw\,1080/ih), pad=1920:1080:(1920-iw*min(1920/iw\,1080/ih))/2:(1080-ih*min(1920/iw\,1080/ih))/2,fps=8,format=yuv420p" -crf 20 video.mp4

The -r 1/2 is the input framerate and determines how long each images remains, in this case, 2 seconds. I've set the output framerate at 8 because some players may fail to play the output. CRF controls the quality. Lower values produce better result but larger files.


For the edited Q:

Use

ffmpeg -framerate 25/15 -i img%03d.jpg -c:v libx264 -vf "scale=iw*min(1080/iw\,1080/ih):ih*min(1080/iw\,1080/ih), pad=1080:1080:(1080-iw*min(1080/iw\,1080/ih))/2:(1080-ih*min(1080/iw\,1080/ih))/2,fps=30000/1001,format=yuv420p" out.mp4
1
  • I've updated my question to be more specific on what I'm trying to do. I've got the files in alphanumeric order at this point.
    – Corey
    Mar 6, 2016 at 20:06
2

You could create an animated gif, using "convert" command from ImageMagick utilities:

convert -delay 500 -loop 0 *.jpg myimage.gif

This will concatenate jpg files, showing every one half a second each, in a permanent loop.

0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .