How To Create Animated GIF In Linux

Create Animated GIF In Linux

Be it a Facebook, Google Plus, Twitter, or any other Social or professional networks, everybody is posting their statuses in GIF format. Because, nowadays, GIF format posts are attracting more visitors than normal images and videos. Animated GIFs are not just for posting funny posts. memes on the web, you can also use them productively to demonstrate a product or a software that you developed to your audience.

Making GIF files is not that difficult. All we need a Linux desktop with FFmpeg, and ImageMagick installed. This method will work in all other distributions as long as they have FFmpeg and ImageMagick installed. As you probably know, FFmpeg is an open source audio, video converter. Using FFmpeg, we can easily stream, convert, and record audio and video files. ImageMagick is an open source software that can be used to create, edit, combine bitmap images.

In this brief tutorial, I will show you how to make animated GIF images in Ubuntu 16.04 LTS desktop.

Make GIF images from a Video

First let us see how to make GIF images from a Video.

As I said, we need to install FFmpeg, and ImageMagick to create GIFs.

FFmpeg and ImageMagick, are available in the Ubuntu official repositories. To install them, run the following command:

sudo apt-get install ffmpeg imagemagick

I am going to convert two video files into GIF format using FFmpeg, and merge them into one file using ImageMagick. Let us see how I did it.

First, convert your first video to GIF format using command:

ffmpeg -ss 00:00:20 -i sample.mp4 -to 10 -r 10 -vf scale=200:-1 cutekid_cry.gif


  • -ss : indicates the starting point of GIF
  • -i : input file
  • sample.mp4 : My video file name
  • -to : End position of the GIF file
  • -r : frame rate. You can increase the value to get more quality GIF file
  • -vf : filter graph. To scale the GIF image in the desired size.

Sample output:

ffmpeg version N-79139-gde1a0d4 Copyright (c) 2000-2016 the FFmpeg developers
 built with gcc 4.8 (Ubuntu 4.8.4-2ubuntu1~14.04.1)
 configuration: --extra-libs=-ldl --prefix=/opt/ffmpeg --mandir=/usr/share/man --enable-avresample --disable-debug --enable-nonfree --enable-gpl --enable-version3 --enable-libopencore-amrnb --enable-libopencore-amrwb --disable-decoder=amrnb --disable-decoder=amrwb --enable-libpulse --enable-libfreetype --enable-gnutls --enable-libx264 --enable-libx265 --enable-libfdk-aac --enable-libvorbis --enable-libmp3lame --enable-libopus --enable-libvpx --enable-libspeex --enable-libass --enable-avisynth --enable-libsoxr --enable-libxvid --enable-libvidstab
 libavutil 55. 19.100 / 55. 19.100
 libavcodec 57. 30.100 / 57. 30.100
 libavformat 57. 29.101 / 57. 29.101
 libavdevice 57. 0.101 / 57. 0.101
 libavfilter 6. 40.102 / 6. 40.102
 libavresample 3. 0. 0 / 3. 0. 0
 libswscale 4. 0.100 / 4. 0.100
 libswresample 2. 0.101 / 2. 0.101
 libpostproc 54. 0.100 / 54. 0.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'sample.mp4':
 major_brand : mp42
 minor_version : 0
 compatible_brands: isommp42
 creation_time : 2015-11-11 07:35:15
 Duration: 00:02:35.76, start: 0.000000, bitrate: 1491 kb/s
 Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p(tv, bt709), 1280x720 [SAR 1:1 DAR 16:9], 1296 kb/s, 23.98 fps, 23.98 tbr, 24k tbn, 47.95 tbc (default)
 handler_name : VideoHandler
 Stream #0:1(eng): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 192 kb/s (default)
 creation_time : 2015-11-11 07:35:16
 handler_name : IsoMedia File Produced by Google, 5-11-2011
Output #0, gif, to 'cutekid_cry.gif':
 major_brand : mp42
 minor_version : 0
 compatible_brands: isommp42
 encoder : Lavf57.29.101
 Stream #0:0(und): Video: gif, bgr8, 500x281 [SAR 1124:1125 DAR 16:9], q=2-31, 200 kb/s, 100 fps, 100 tbn, 100 tbc (default)
 handler_name : VideoHandler
 encoder : Lavc57.30.100 gif
Stream mapping:
 Stream #0:0 -> #0:0 (h264 (native) -> gif (native))
Press [q] to stop, [?] for help
frame= 240 fps=110 q=-0.0 Lsize= 9572kB time=00:00:10.00 bitrate=7841.4kbits/s speed=4.57x 
video:9569kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.027768%

That’s it. We have successfully created a GIF file from the Video.

Combine multiple GIFs into one

You can combine GIF images. Just make as many GIFs as you want as shown above, and save them in the same folder.

Then, run the following command to combine all of them:

convert -delay 120 -loop 0 *.gif cutekids_crying.gif

Create GIF from a list of images

We see how to create a GIF image from a video. Now, we will see how to create a GIF from a list of images.

Go to the folder where you kept all the images, and run the following command from the terminal to create a GIF file.

convert -delay 120 -loop 0 *.jpg linux.gif


  • -delay 120 : The GIF animation speed
  • -loop 0 : Infinite loops of the animation.

That’s it. Your GIF is ready.

Click the following link to view my GIF file created from a Video (It’s big size GIF file, it will take few minutes to load).

Hope this helps. If you like this tutorial, share it on your social networks and support OSTechNix.


Thanks for stopping by!

Help us to help you:

Have a Good day!!

You may also like...