In research sometimes you want to make a movie from single images, like plots from experimental data or from calculation to visualize changes or so on. In order to achieve this you can use ffmpeg. First you have to create the images and save them, where the images need to have a continuous number in the filename, e.g. img0001.png, img0002.png, …, …img5467.png. Take care that there is no image missing and that you have enough zeroes in front of the image number, so that the files are in the correct order.
After you have all the images in a folder, install ffmpeg, in Ubuntu/Debian Linux e.g.
sudo apt-get install ffmpeg
In order to make a movie (mp4 quicktime) out of the images you need to issue the following command
ffmpeg -qscale 5 -r 20 -b 9600 -i img%04d.png movie.mp4
The options are
- -qscale 5 … define fixed video quantizer scale (VBR) where 1 is the best and 31 the worst. Since mpeg/jpeg has problems to compress line graphics it’s a good idea to set this variable close to 1. You get a big movie file, but otherwise the movie doesn’t look, well, that good.
- -r … framerate
- -b … video bitrate
- -i input files, %04d says that we have four numbers in the filename where the number is filled with zeros left of it.
- movie.mp4 is the filename, the extension says that it is a quicktime movie. You can also create a Macromedia Flash movie by using the .flv extension.