Making Animated GIFs

Using open source tools to create small but high quality animated gifs

Khairil Yusof
2 min readJul 27, 2019

First we convert the video into individual frames using ffmpeg into a temporary folder. 5 frames per second is usually good enough, for screen capture animations. You can bump this number up if the source video has a lot of rapid movement.

ffmpeg -i hluttaw-committee.mp4 -r 5 frames/frames%03d.png

We will use GIMP Image Editor to create the animated GIF. First we import the frame images as layers.

Next, we need to reduce unneeded information between frames to reduce size of the GIF. For example if 2 consecutive frames have the same background, then the second one only needs to have the parts that have changed added to the first one, and need to have data for the whole frame image. We use GIMP’s Animation Optimize Filter for this.

After the filter is done, you can optimize the quality of the GIF you wish to export by changing the image from RGB to indexed. GIF only has support for 8bit palette of 256 colors per image. To make the images look smoother and closer to their original colors, you can choose option to have dithering. This can make the GIF much larger, so might not want to do this for longer animations. For shorter animations, with photos and images you probably would prefer to dither and have the GIF to be few megabytes larger, but look much nicer.

The final step is to Export As, and save the file as a GIF. Check the As Animation checkbox and export.

And here is the final output for my screencast of OpenHluttaw website.

--

--