FFMPEG An Intermediate Guide/image sequence
FFMPEG has a powerful set of features relating to creating video from images, or generating an image sequence from a video.
Making a video from an Image Sequence
FFMPEG can create video from images 
ffmpeg -f image2 -i image%d.jpg output.mpg
ffmpeg -y -an -qscale 4 -i '~aframe-%06d.png' '~a'
Input file formats
To see the supported input formats, use :
Names of input files
Making a video from an image sequence is relatively easy if the images are named correctly.
Images need to have a continuous number in the filename, e.g. :
Take care that :
- there is no image (number) missing. If it does, ffmpeg will assume the sequence is over and stop adding more images
- specify the width of your index. That is, make sure "you have enough zeroes in front of the image number, so that the files are in the correct order."
%05d is explained in-depth under video to image sequence
In short %05d will be replaced with numbers starting with 0, and will be padded with four zeros, e.g. 00000, 00001, 00002, 00003 ... so file names will appear as input_00000.jpeg, input_00001.jpeg, input_00002.jpeg, input_00003.jpeg ...
ffmpeg -f image2 -i "input_%05d.jpeg" -r 25 output.mov
Use the ‘-start_number’ option to declare a starting number for the sequence. This is useful if your sequence does not start with ‘input_00000.jpeg’ but is still in a numerical order. The following example will start with ‘input_00100.jpeg’:
ffmpeg -f image2 -start_number 100 -i "input_%05d.jpeg" -r 25 output.mov
You can also use a filename pattern, example:
ffmpeg -f image2 -pattern_type glob -i "*.jpg" -r 25 output.mov
You need to specify the rate (-r) you want the sequence to play back at :
- 12 (stop motion).
If you use PAL, NTSC or HD, please ensure that pictures are the right frames size. If you don't need to go to interlaced formats, such as PAL or NTSC, don't as this will affect quality of play back. if you final product is for PAL or NTSC TV, you may only want to interlace as part of the final step of preparing the footage for broadcast or DVD.
Making an Image Sequence from a video
Making an image sequence is a relatively simple process but there are a couple things to keep in mind.
You need to use %05d in the file name, this will add the frame number to the end of the images name. If you do not do this you will most likely end up with FFMPEG overwriting the same frame, leaving you with only the last frame accessible.
Interlacing does not have solid frames, and if the footage has not come from a television-type source, there no way to recover the progressive frame. This means that the two interlace fields will need to be merged to make one frame. which will introduce some loss of quality. If you plan on doing this at any stage in a production, you should make a new high quality master to work from or you could problems moving back to the source with edited footage.
_%05d Is a numerical place holder and broken up as follows.
- _ (under score) is just there to make reading the produced file name easier and can be removed.
- % (percentage sign) indicates a special piece of code to follow for FFMPEG.
- 0 (zero) what character is used to pad the sequence, this often help programs associate sequences more easily.
- 5 (numerical value), how may placeholders there should be this should generate 99 999 picture frames. (+- 1hour 6min of Pal video)
- d tell FFMPEG to use decimal and will count using whole integers.
ffmpeg -i "input.mov" -an -f image2 "output_%05d.jpg"
Error messages and Warnings
- This module returns a very basic error message:
- Koons_009%05d.dpx: no such file or directory
- This gives you very little to go on. Is ffpmeg built to handle image sequences or have you simple told it to search for the wrong file?
- In this case the file name was: Koons_0090000.dpx
- The correct requested file should have been: Koons_009%04d.dpx
- Normally FFMPEG is built correctly to handle sequences. else try testing it on a simple sequence.
- FFMPEG looks for a file that starts at 0. e.g. Koons_0090000.dpx. It will fail if the first image was Koons_0090001.dpx
- FFMPEG will then keep running till it reaches a number break.
- Images need to be generated at TV standard size if you want to use them in DVDs and such.
- HD: ffmpeg -f image2 -i "Koons_009%04d.dpx" -r 25 -b 50000000 -s 1920x1080 -an "output.mov"
- PAL: ffmpeg -f image2 -i "Koons_009%04d.dpx" -r 25 -b 50000000 -s 720x576 -an "output.mov"
- NTSC: ffmpeg -f image2 -i "Koons_009%04d.dpx" -r 25 -b 50000000 -s 720x480 -an "output.mov"
- Images do not have sound by default so you need to add it, so add the audio as a second input file.
- ffmpeg -f image2 -i "Koons_009%04d.dpx" -i "soundtrack.wav" -r 25 -b 50000000 -s 1920x1080 -an "output.mov"
- Could not get frame filename from pattern means "you have to use only %d, if you have %'s use %% to escape them"