ffmpeg an image sequence

2

I want to encode a sequence of images to an video file, I have done this in the past with something like:

ffmpeg -i %08d.jpg out.mp4

But first I had to rename the files to be in that %08d.jpg format. I want to just encode them and let them be in alphabetical order (or whatever) without having to rename them, is this possible? I tried with using *.jpg and ffmpeg just hung and eventually crashed.

wim

Posted 2012-10-23T12:19:14.977

Reputation: 2 523

1Not possible by default. *.jpg will simply expand to all filenames before FFmpeg even sees the asterisk. Why couldn't you just rename the files, if I may ask? Or copy them somewhere else, then rename? Maybe you can pipe the images into FFmpeg similar to cat *.jpg | ffmpeg -f image2 -i pipe: -r 25 out.mp4? – slhck – 2012-10-23T12:31:19.650

You can do it with Symbolic Links to your list of files... Have a look at this link to give you an idea: Sort images by aspect ratio

– Peter.O – 2012-10-23T16:21:48.113

I do currently just rename the files, with a little python script, but it's a kludge and I thought it likely there was a more elegant solution I wasn't aware of. The symbolic link thing had occurred to me, too, but it's really just as much work as renaming the files anyway. I will try the pipe thing next... – wim – 2012-10-24T00:30:14.037

Have you tried the pipe already? Would be interested to see if that works – slhck – 2012-10-29T15:07:38.400

No, it didn't work. But on reading the man pages to try and figure out the syntax to make it work, I saw something else which solved the problem. I'll post it as an answer.. – wim – 2012-10-31T12:22:51.980

Answers

3

It is actually possible to let ffmpeg actually handle the glob for you. Use the -pattern_type option from the image2 demuxer and wrap the glob in single quotes to prevent expansion:

ffmpeg -f image2 -pattern_type glob -i '*.jpg' out.mp4

For older versions of FFmpeg, you could use the % character, for example:

ffmpeg -i %*.jpg out.mp4

The above is however considered deprecated.

wim

Posted 2012-10-23T12:19:14.977

Reputation: 2 523

ffmpeg Error: Pattern type 'glob' was selected but globbing is not support ed by this libavformat build: "glob is defined in the POSIX standard and it's not available on Windows by default." – Franck Dernoncourt – 2017-07-06T17:22:55.453

Wouldn't just '*.jpg' (note the apostrophes) work just as well, and be a little more familiar since it doesn't rely on a tool-specific syntax? – a CVn – 2012-10-31T12:38:08.177

nope, and that doesn't work at all. it's explained why in the man pages. – wim – 2012-10-31T13:15:24.847

Be aware that the syntax you were using is considered deprecated and might be removed soon. I added the new syntax from the latest version of the FFmpeg manual but kept the old version as well. – slhck – 2012-11-02T19:36:38.820