Do you like gifs?
Do you wish you knew how to make them yourself?
Do you want to make them without spending any money?
Then you're in luck. Below the cut, I've written a tutorial describing how to make a gif from video by using GIMP.
Warning: This is image-heavy.
Table of Contents
First Things First
- You need GIMP and GAP (the Gimp Animation Package) installed on your computer.
- (Download GIMP v2.6 from their website)
- (Download GAP v2.6 compiled for Windows XP and Vista from here)
- You need the video to be saved on your computer (this can't extract frames from streaming video).
- Open GIMP.
Extracting Frames From Video
First you're going to need to tell GIMP which video you want to extract frames from, and which frames you want to extract.
- Select Video > Split Video into Frames > Extract Videorange
- Click the ellipsis button ( . . . )
- Find and open the video you want.
- Set the value for Audiotrack to 0.
- (If you don't, extracting the video will create a file called frame.wav. This is the audio from the scene you're turning into a gif. You can delete this.)
- Under Output, check Create only one multilayer image.
- Enter the numbers of the first and last frames into the From Frame and To Frame boxes if you know them
- Click the Video Range button on the right, under the ellipsis button, if you don't know the frame numbers.
- Drag the bar to about where in the video you want your gif to start.
- Use up & down arrows (onscreen or keyboard) to fine tune the frame display.
- Click the small button to the right of the frame number to set that frame as the first frame of your gif.
- Go forward in the video and find the last frame you want to extract.
- Click the larger button to the right of the frame number to set that frame as the final frame of your gif.
- Click OK.
- (If the file is very large or your computer is slow, Select Videorange may not work.)
- Wait for GIMP to finish Seeking Frame Position and Extracting Frames.
- (The more frames you try to load and the larger the dimensions of the frames are, the longer this will take. A few dozen 624x352 frames from an avi take only a few seconds, but over 500 1280x720 frames from an mkv took my crappy computer about an hour.)
Playback
You should watch what you've extracted to make sure it's what you want. Check to see if you're missing any frames at the beginning or end, or if you have any extra frames that you should delete. You can perform a playback at any stage of making your gif.
- Select Filters > Animation > Playback. This will open another window.
- The Play button plays and pauses.
- The Step button allows you to move forward one frame at a time.
- The Rewind button takes you back to the first frame.
- At the bottom, the % dropdown menu allows you to watch the animation at different speeds (without actually changing the speed the frames are set to play back at).
Extra Frames & Frame Rate
Each frame of your video is now its own layer. These layers can be deleted, duplicated, cropped, have their speed adjusted, etc.
- Over in the Layers window (on the right), you can see the list of frames.
- Only the topmost layer with the eye to the left is seen in the main window. You can change which frame you're viewing in the main window by clicking the eye off of the top layer and clicking it on any other layer.
- Delete any extraneous frames, if you have them. Right click > Delete Layer or drag them to the trash can on the bottom right (or if you have a lot in a row, the arrow keys and Menu key > D works well too, because you can't select more than one layer at a time).
- The number in parenthases is how long the frame is seen in milliseconds (41ms in this example). It will automatically be set to the speed that the video plays at, and ought to correspond with the frame rate you can usually find in the properties window.
- (If they're set to something like 0ms or 100ms, hold tight, I explain what to do about that near the end in the section on saving your animated gif.)
- If you want to make a variable-speed gif (like this one, for example) you can manually enter different speeds into each one (right click > Edit layer attributes or Menu key > E), but I wouldn't recommend trying it. It's kind of a pain in the ass.
Resizing
Unless the source video you used was just the right size, you're gonna have to resize your gif.
- Select Image > Scale Image
- Enter your preferred width and/or height
(The little chain link to the right keeps the aspect ratio locked, so you only have to set one and it will set the other for you).
Choose which quality Interpolation from the drop-down menu you'd like.
- (I chose cubic, but you can see this GIMP doc about Interpolation to decide which you ought to choose.)
Indexed Colors
Gifs have a palette limited to 256 colors. Chances are, your video contains many more. You'll have to convert your image from the RGB colorspace to Indexed colors in order to save your clip as a gif. To prevent color banding (the weird blotches and streaks you sometimes see on gifs), you'll have to utilize the dithering option. If your gif is black & white, skip this step.
- Select Image > Mode > Indexed...
- Check Generate optimum palette
- Set the Maximum number of colors to a value between 1 and 256.
- (A smaller number will yield a smaller file, but of lower quality. Play around with it; you can always undo.)
- Select Positioned under Dithering.
- (It seems that Positioned works best for animations, but you can also try the other two Floyd-Steinberg dithering options in the dropdown menu if you'd like.)
- Click Convert.
- (If you convert to indexed colors manually, instead of letting GIMP do it automatically upon saving, you'll usually wind up with a better looking gif, but it will also be bigger. Since TinyPic and other image hosting services have a maximum size or bandwidth limit, you may want to try a few different values in Maximum number of colors, and choose the smallest number with the best quality.)
- (Here is the GIMP doc on Indexed colors and Dithering.)
Compare these pairs of gifs. The first of each pair was converted to indexed colors by using the process above; the second of each pair was converted automatically when saving.
Converted Manually (max # of colors: 140) Converted Automatically
Converted Manually (max # of colors: 256) Converted Automatically
Optimizing
This will decrease the size of your completed gif by eliminating redundancies. It will create transparent areas in each frame where the pixels are identical to the one beneath it.
- Select Filters > Animation > Optimize (for GIF).
- (Optimize (Difference) works too -- they do practically the same thing -- but in my experience, (for GIF) is just slightly smaller in final size, when there's any difference at all. Try both to see which works best for your gif, if you'd like.)
- A new window will open with the optimized frames.
- (You can optimize before or after converting to indexed colors.)
Saving
You're almost done! Now you just have to save it.
- Select File > Save As (or Shift+Ctrl+S)
- Choose where to save your file.
- Type .gif on the end of the name, or choose GIF Image under Select File Type (By Extension).
- (If the extension isn't specified, it will automatically be saved as .xcf .)
- Click Save.
- Check Save as Animation when the Export File window opens.
- Click Export.
- (If the Export File window has an option between Convert to Indexed using default settings and Convert to grayscale like this, then you skipped the step on converting to indexed colors above.)
- Check Loop forever when the Save as GIF window opens.
- You can choose whether or not you want the gif to be interlaced, or to have a comment.
- Adjusting Delay between frames... is unnecessary, as all of your frames already have a delay specified (41ms in my example).
- Leave Frame disposal where unspecified as I don't care
- (Like the frame delay, the frame disposal is already specified; Optimize (for GIF) marked all layers as combine).
- If your frames are set to 0ms (or 100ms), or after opening your gif in your internet browser, it's too slow or too fast, you can fix that by resaving your gif:
Enter a different number into the Delay between frames where unspecified box, then check Use delay entered above for all frames and re-save it to change the speed of all the frames in the gif. That will reset the speed for all frames.
- (Most tv shows and movies are 23 or 24 frames per second, and would be set to 43ms or 41ms. Most of the files saved from YouTube are 30fps, which would be 33ms.)
- (GIMP only saves multiples of ten [30ms, 40ms, etc].)
Your Finished Gif
Congrats! You can now gif damn near anything you want.
This process may be bit difficult the first few times you do it, but once you get the hang of it, it's really easy.
Also, please let me know if I was unclear about anything, or ask if you have a question about something that I didn't cover in the proper detail.