Animated GIFs are very popular right now and they are very easy to create. We’ll use FFmpeg, a leading multimedia framework, to convert your video to a animated GIF image.

Example of an animated GIF

The following is an example of an animated GIF I created from a iPhone video I made.

Convert Video to GIF

The video is an Apple QuickTime movie that is 1 second in length, 1.5MB in size, and 1280 pixels wide and 720 pixels high.

Convert video to animated GIF

Simply, type the following command to convert your video to an animated GIF in FFmpeg:

ffmpeg -i video.ext picture.gif

Make sure you change .ext to the video file extension, such as .mov or .mp4.

If you want to convert only a portion of the video to an animated GIF, use the following command:

ffmpeg -t 5 -i video.ext picture.gif

You’ll notice, we’ve add -t 5 to the start of the command, which will make the animated GIF five (5) seconds in length. Change the 5 to however long you want the animated GIF to last.

When we made the animated GIF five (5) seconds. It is five (5) seconds from the start of the video. So, let’s say the video is 15 seconds in length. The animated GIF would be from the beginning to the first five (5) seconds and six (6) to 15 seconds would not be included in the animated GIF.

So, what if you wanted to started the animated GIF at a certain point in the video, let’s say at the eight (8) second mark. The command would be:

ffmpeg -t 5 -ss 00:00:08 -i video.ext picture.gif

Something you might want to look into is the size of the animated GIF. My .mov video is only one (1) second long with a file size of 1.5MB, but when I converted it to GIF, the file size became 5.55MB. So, do I need the animated GIF to be 1280×720 pixels? Can I make it smaller to achieve a smaller file size? Well, we can use the scale filter to change the size:

ffmpeg -i video.ext -vf scale=width:height picture.gif

In the above command I scaled the animated GIF from 1280×720 pixels to 640×360 pixels by adding -vf scale=width:height in between the video filename and the GIF filename. Make sure you change width and height with how big the animated GIF should be, which can be a pixel or ratio amount. For this tutorial’s example, the new file size is 1.5MB.

We can also change the bit-rate like so:

ffmpeg -i video.ext -b 2048k picture.gif

Have fun creating animated GIFs from videos!