Converting gif animations to mpq files on Ubuntu

By Andreas Schickedanz Apr 19, 2013

I am planing to record some screencasts about coding, hardware hacking and gaming. But as you all know a good screencast does not only consist of a nice recording, but also a nice intro and a nice outtro (also called “extro”). So I created a nice looking wallpaper and a friend of mine composed a really cool song for me. Thanks Fabi! Using the OpenShot video editor it was very easy to combine these two and then I just had to add some animated text.

However, all text animations offered by OpenShot did not meet my needs, so I decided to create my own using the Gimp. After about two hours of work, several coffees and much copy ‘n paste I had a nice animation of typed text. I exported my Gimp project as animated gif file and added it as a new track to my OpenShot project. Nothing happend. The gif was added but when I viewed the preview of my intro I just saw the first image of my gif animation. Just a short lookup and everything was clear - OpenShot is not able to handle animated gif files. Two hours of wasted time.

After a short freak out and a cup of coffee I decided to check if it is possible to convert an animated gif file to any useable video format. And now the good news: It is possible!

Most solutions I found suggested a combination of ImageMagick and ffmpeg. Using the convert command of ImageMagick you extract each frame as.jpg/jpeg file:

convert animation.gif frame%05d.jpg

This should create a bunch of files, which could then be combined to a mpq video using the command below.

ffmpeg -i frame%d.jpg video.mpg

In my case this did not work, but since it does for most users, I would like to at least mention that.

But, fortunately for us, there is an other solution using mplayer and ffmpeg. Using mplayer you extract each frame as a.jpg file.

mplayer -vo.jpg animated.gif

In my case running this command created a bunch of about 100 files, which were then fed into ffmpeg to create the mpq video file.

ffmpeg -r 25 -i %08d.jpg video.mpg

In this case the parameter -r specifies the number of milliseconds a frame is displayed and the names of the input files which are named by mplayer with an 8 digit number (including leading zeros) followed by the file extention .jpg.

Thanks to this solution I was able to add my typed text animation to my screencast intro. Which I will hopefully present you next time. Then I will talk about writing python scripts and plugins for the Gimp.

Stay tuned and until next time, happy converting!


is a Computer Science MSc. interested in hardware hacking, embedded Linux, compilers, etc.