Convert MPEG/AVI video to animated GIF

Image credit: Frank Starmer

Today a friend asked me how to convert an MPEG video file into an animated GIF file and I would like to share here our findings.

In Linux (e.g. Ubuntu) you can use the FFMPEG and ImageMagick tools to do the following:

Convert an MPEG file into an AVI file

Convert an AVI file into an animated GIF file

Now, if you get the following error after the last step

you can do what it’s suggested and re-run the last command like this

Note: It matters to put

where it’s indicated, otherwise you may get an


At this point you may have ended with a fairly large GIF file. Here is where we can use ImageMagick to reduce its size using

If your final gif file is still too large, an option may be to select only one segment of your original MPEG file to convert it into an animated gif. For this you can do, for example:

Here, we are seeking to the 13 seconds position and set the duration of the segment to 9 seconds.

Finally, perhaps you want your animated gif playing in an infinite loop. We can use ImageMagick convert command:

For Windows, there is the following software that looks promising for achieving our objective: Movie to animated GIF converter

For Mac OSX, here is an example of a commercial software that offers to do what we want: Xilisoft Video Snapshot for Mac

What is your solution of choice to convert MPEG/AVI video files into animated GIF files?

Related links:

How can I get ffmpeg to convert a .mov to a .gif?

19 ffmpeg commands for all needs


Leave a Reply