Ubuntu 16.04 How to create animated GIF

On Facebook, Google Plus, Twitter, or any other Social, networks, everybody is posting their statuses in GIF format. GIF format posts are attracting more visitors than normal images and videos.

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.

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.

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

Here,

-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.

That’s it. Your GIF file from the Video is ready.

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

Here,

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

That’s it. Your GIF is ready.

Source: ostechnix.com