Kemp’s Blog

A technical blog about technical things

Convert images to video in Linux

On occasion I need to convert a series of images into a movie. For example, I have a data visualiser which generates an image for each timestamp and it nice to be able to use these to view the evolution of the sensed values over time. If you search on this topic then you’ll find a lot of people suggest using ffmpeg with a command line such as the following:

ffmpeg -r 10 -b 1800 -i %03d.jpg test1800.mp4

However, this assumes that all the filenames are sequentially numbered and that there are none missing (it will finish when it reaches the first missing number). I needed something a little more flexible, and eventually found this page which suggests the following:

mencoder "mf://*.jpg" -mf fps=10 -o test.avi -ovc lavc -lavcopts vcodec=msmpeg4v2:vbitrate=800

This will simply read the files in the usual alphabetically sorted order. You can change “mf://*.jpg” to adjust which files it uses, along with tweaking the framerate and bitrate.

Contrary to the note on that page, more recent versions of mencoder support png files as input.