How to Make an Animated GIF from Video

Album Cover: No Line On The Horizon

"I'm running down the road like loose electricity while the band in my head plays a striptease."
U2 / Breathe

Posted on August 16, 2009 11:07 AM in Computers
Warning: This blog entry was written two or more years ago. Therefore, it may contain broken links, out-dated or misleading content, or information that is just plain wrong. Please read on with caution.

My wife spends a lot of time over at OH NO THEY DIDN'T, a celebrity gossip site. Anyone who knows that site knows that its readers love their animated GIFs. My wife always says things like "I wish I had an animated GIF of that," and I've always wondered what it took to make one from video (yes, we're geeks). Today I decided to find out.

Amazingly enough, there doesn't seem to be a definitive source online for this information. There's this silent tutorial on YouTube that looks to require, at minimum, MediaCoder and GIMP. There's also this somewhat frightening YouTube walkthrough that seems to require a recent version of Photoshop. It wasn't until I stumbled upon Making Animated GIFs With Free Software in Four Steps that I saw something I might be able to work with.

As is typical with such posts, some of the information provided in the comments was actually more useful than the post content itself. Unfortunately, though, no one put the pieces together into one single, coherent walkthrough of how animated GIFs can be made from a video clip. That's where I come in.

The great thing about the information found at that site is that it applies to both Windows and Linux (and therefore likely Mac as well). In the end, all you end up needing to have on the software side of things is MPlayer (which I've covered here before), which can be had by downloading the "MPlayer SVN Windows with SMPlayer GUI" option from here or by typing apt-get install mplayer from the command line on Linux.

As the commenter natonelbronx pointed out in the aforementioned comments, it's possible to make a single command line call to mplayer.exe (Windows users will find mplayer.exe in a subfolder named "mplayer" underneath the root "SMPlayer" installation directory) to generate an animated GIF from a video file. What he didn't know, though, is that his method results in inferior color quality when used. Fortunately for me (and anyone else looking to create an animated GIF from video in one easy step), an anonymous commenter provided a better option, which takes advantage of MPlayer's additional video formatting options to ensure the color quality is much richer.

After combining the tips from both commenters, I ended up with the following command line call, which should look the same on either Windows or Linux, with the exception of the ".exe" part not applying to Linux:

mplayer.exe ghostbusters.mkv -ss 32:35 -endpos 7 -ao null -vo gif89a:fps=10:output=ghostbusters.gif -vf palette,rgb2bgr,scale=240:135

Here's a breakdown of what's going on in that command line call:

  • "ghostbusters.mkv" is the name of the video file I'm using to generate the animated GIF.
  • The -ss argument is used to tell MPlayer to start the GIF at the 32 minute and 35 second mark of the video file.
  • The -endpos argument tells MPlayer to stop the animated GIF 7 seconds after the starting point.
  • The -ao null argument/value pair tells MPlayer not to worry about sound, since that isn't needed for an animated GIF.
  • The -vo argument tells MPlayer how the video output should be formatted (gif89a makes the output a GIF, fps=10 sets the frame rate to 10 frames-per-second, and output=ghostbusters.gif gives the output a file name).
  • The -vf argument is the trick for making sure the colors are richer in the output, with the scale portion providing the dimensions of the resulting animated GIF (you'll want to keep this scale rather small because animated GIFs have a tendency to grow in file size very quickly).

In the example, I converted an MKV file, but I've seen this same call work for AVI and MP4 files as well. I assume any video format MPlayer can play should work just fine. The command only took a few seconds to run, albeit on a beast of a computer, and when it was done, I had generated the following animated GIF:

Animated GIF of a Clip from the Movie Ghostbusters

(You might need to give it some time to load since it's about half a MB in size).

So there you have it -- an easy way to generate an animated GIF from a video file without the hassle of expensive software or multiple steps. Have fun!


Indylavi on August 27, 2009 at 9:01 PM:

Hello, I'm a member of ONTD and sutbled upon your site on a google search. I wrote a tutorial on how to make an animated gif using VirtualDub and ImageReady. I posted that here

Watch out clicking on the thumbnails. I posted those before Imagevenue started putting their ads on links. So the adds may be NSFW :( They started putting some stupid dating site ads. I use tinypic now for that reason.

Anyway, It depends on the users computer. If you are using a windows PC. There are plenty of Options. You can use the above method with GIMP if you don't have Photoshop ImageReady. As both GIMP and VirtualDub are free programs. Just export video as an imagesequence in Virtualdub and import files as frames in GIMP.

A good non free program is Ulead. But that will only convert AVI files. But these programs only work on PC and not a MAC.


Joe on October 08, 2009 at 9:16 AM:

Thank you! This is exactly what I needed.


Matt on March 19, 2010 at 12:00 AM:

Yeah, this creates GIFs, but as you may have noticed, the quality of them really, really sucks.


anonymous on September 12, 2010 at 11:41 PM:

But how do you run the command to begin with?


Anonymous on September 27, 2011 at 5:47 AM:

This method makes low-quality gifs because mplayer's gif89a output converts them to 256 colors (8-bit; says its documentation). For 32 or 24-bit gifs (high quality), start with the method from his source site:

...BUT use these "vo" and "vf" command options instead of the site's "vo/vf" options:

-vo png:z=9:outdir=moviedirectory -vf pp=al,scale=240:135

Then, use GIMP or ImageReady to change the image color's mode to "indexed", optimized with dithering. "Save as" an animated gif with a delay between frames, and enjoy.


Anonymous on September 27, 2011 at 6:43 AM:

@comment 11:41
You type/paste it in a Command Prompt (Terminal). If you're on Windows, look in the Start menu -> All Programs. If you don't see "Command Prompt", open Start menu -> Run, and type "cmd.exe". If you're on Linux, open a terminal window.

Before typing the mplayer command, learn to use the "dir" and "cd" commands (Google them) to navigate between folders from the command prompt. This is essential for typing the proper location of your movie file in the mplayer command and for specifying where mplayer saves its output images. The mplayer command will save its images inside whatever folder you're currently inside of on the Command Prompt.

To make it easier, put your movie in your "My Documents" folder, and run all commands from that folder. (so you only need to give mplayer filenames like "ghostbusters.avi", not full paths like "D:savedvideosghostbusters.avi")


Anonymous on September 27, 2011 at 7:23 AM:

256 colors is not necessarily 8-bit. Gifs can have a palette of any 256 colors selected from the 24-bit color space. The high-quality difference comes with indexing optimizations (to select better colors) and dithering (to give the illusion of blended colors) in GIMP or ImageReady.


Do Short Sales Still Help Homeowners? on October 31, 2011 at 9:48 AM:

I LOVE this post! I have been researching this topic and I appreciate the hard work that went into this post. I will be back very soon for more detailed information. Thanks again! Awesome Job!


Gif Man on January 01, 2012 at 1:20 PM:

This application provides a simple way to get the job done:


ErrorReporter on October 20, 2014 at 2:24 AM:

With the newest version of mplayer.exe, the option -vf isn't valid anymore:

Option vf: rgb2bgr doesn't exist.
Error parsing option on the command line: -vf


ErrorReporter on October 20, 2014 at 2:29 AM:

Ups, wrong interpretation!

-vf palette, rgb2bgr, scale=240:135

You need SPACES after the comma (at least for Windows). Otherwise, the command isn't valid


Manual Niche Relevant blog comments on September 05, 2016 at 2:49 AM:

A debt of gratitude is in order for your knowledge for your fabulous posting. I'm happy I have set aside an ideal opportunity to see this.


minecraft play free on September 28, 2016 at 5:30 AM:

I was reading your article and wondered if you had considered creating an ebook on this subject. Your writing would sell it fast. You have a lot of writing talent.


netflix password and username on September 28, 2016 at 5:30 AM:

I went over this website and I believe you have a lot of wonderful information, saved to my bookmarks


hokidqet on May 15, 2017 at 5:23 AM:
Niky Eddie on March 17, 2018 at 2:25 PM:
fluoxymesterone on December 04, 2018 at 9:01 AM:

Very interesting, good job and thanks for sharing such a good blog.


Post Comments

If you feel like commenting on the above item, use the form below. Your email address will be used for personal contact reasons only, and will not be shown on this website.


Email Address:



Check this box if you hate spam.