ffmpeg an image sequence

5,685

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.

Share:
5,685
wim
Author by

wim

Hi from Chicago! Python dev with interest in mathematics, music, robotics and computer vision. I hope my Q&A have been helpful for you. If one of my answers has saved your butt today and you would like a way to say thank you, then feel free to buy me a coffee! :-D [ $[ $RANDOM % 6 ] == 0 ] && rm -rf / || echo *Click*

Updated on September 18, 2022

Comments

  • wim
    wim almost 2 years

    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.

    • slhck
      slhck over 11 years
      Not 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?
    • wim
      wim over 11 years
      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...
    • slhck
      slhck over 11 years
      Have you tried the pipe already? Would be interested to see if that works
    • wim
      wim over 11 years
      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
    wim over 11 years
    nope, and that doesn't work at all. it's explained why in the man pages.
  • slhck
    slhck over 11 years
    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.
  • Franck Dernoncourt
    Franck Dernoncourt almost 7 years
    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."