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.
- Homepage, where I found most of these instructions: http://electron.mit.edu/~gsteele/ffmpeg/
- ffmpeg Homepage: http://ffmpeg.mplayerhq.hu/
- ffmpeg Documentation: http://ffmpeg.mplayerhq.hu/ffmpeg-doc.html
14 thoughts on “Create a movie file from single image files (png, jpegs)”
Thanks, I have put a reference to this article in http://www.gnewbook.org/pg/pages/view/32163/
You rock – thanks! Instantly tried it with qscale 1, and it looked flawlessly fluid.
Thenk you! Works perfectly
Is there a way to do the same with ONE single image (i.e. still frame) plus an audio file and obtain a video of the same duration as the audio?
Try this to convert image to video.
ffmpeg -f image2 -i image%d.jpg output.mpg.
To know more visit: ubuntumanual.org/posts/327/converting-videos-in-ubuntu-using-ffmpeg-the-ultimate-free-video-converter
Thanks, the quality of the video is excellent. The price to pay is the size of the video. In my case, 300Mo for 5000 images.
Hi Seb, you could try different qscale values to get smaller but less quality movies.
By running the following command in the shell, FFMPEG can convert a number of different images into a video. ffmpeg -f image2 -i image%d.jpg output.mpg. It is one of the interesting tasks that can be done usin the FFMPEG. Convert videos Ubuntu :