Best of Linux

Best GIF Maker Apps for Linux

GIF animations are a popular way to share fun animations, jokes and short clips of just about anything and it is hard to miss them these days on the Internet. They are used widely in social media, blogs, software documentation, game development etc. to quickly showcase something that cannot be expressed in static images. Even though they are limited to a 256 color palette, their usefulness lies in creating lossless animations that are relatively easy to create and share.

This article will list various offline desktop apps that can be used to create GIF animations on Linux. Some of these apps record a GIF directly while others convert a video file into a GIF animation.

FFmpeg

FFmpeg is a command line utility to convert and record audio and video streams. It comes with numerous command line switches that can be used to configure the output as per your needs.

FFmpeg can be installed in Ubuntu by running the command below:

$ sudo apt install ffmpeg

To convert a video file to GIF using FFmpeg, you will have to first create a color palette from the input video. This palette will be a sample of accurate colors picked from the video itself. It is possible to omit creating a palette altogether and jump straight away to GIF creation. However, the resulting output quality may not be good as FFmepg will automatically use a palette created from generic 256 colors. The accuracy of these generic colors can be totally off from colors used in the input video. So it is generally a good idea to always create a palette from input file.

To create a color palette from video, run a command in the following format:

$ ffmpeg -i input.mp4 -filter_complex "[0:v] palettegen" palette.png

Where:

  • -i input.mp4 is the name of the video file to be used as input
  • -filter_complex is an option available in FFmpeg to specify multiple filters
  • [0:v] specifies stream order for the filter, “v” stands for video and “0” stands for first stream (input.mp4 in this case)
  • palettegen is the name of the filter to be used

Now that the palette is created, you can use it to convert the original video file to GIF. Run a command below in the following format:

$ ffmpeg -i input.mp4 -i palette.png -filter_complex "[0:v][1:v] paletteuse"
 -r 10 output.gif

Where:

  • -i palette.png is the name of palette file created above
  • [0:v][1:v] stands for stream order, 0 is for input.mp4 and 1 is for palette.png
  • paletteuse is the name of filter to be used in conversion, it takes two arguments in the form of [0:v][1:v]
  • -r 10 is the frame rate of the output GIF file
  • gif is the name of the resulting GIF file

Byzanz

Byzanz is a command line tool to record videos and animated GIFs on your desktop. It supports a delay timer, audio capture and mouse cursor capture.

To install Byzanz in Ubuntu, run the following command:

$ sudo apt install byzanz

To record an animated GIF, run a command in the following format:

$ byzanz-record --duration=15 --x=100 --y=200 --width=600 --height=800 out.gif

Where:

  • –duration is the elapsed time period after which recording will stop automatically
  • –x is the X coordinate of the rectangle you want to record
  • –y is the Y coordinate of the rectangle you want to record
  • –width is the width of the rectangle you want to record
  • –height is the height of the rectangle you want to record

It can be difficult to exactly determine coordinates and geometry, especially when you want to record a focused application window while ignoring everything else on the screen. This issue can be solved by installing a keyboard and mouse simulator app called “xdotool”.

To install xdotool in Ubuntu, run the command below:

$ sudo apt install xdotool

Now to get the geometry of the focused window, run command:

$ xdotool getwindowfocus getwindowgeometry -shell

You will see output like this:


WINDOW=81788938
X=937
Y=216
WIDTH=836
HEIGHT=559
SCREEN=0

Just plug these values in Byzanz command explained above.

Peek

Peek is a simple and easy to use video and GIF recorder for Linux. The app is mainly designed for recording a selected area on the desktop and there is no fullscreen or audio recording support.

Some of the main features of Peek include customizable hotkeys for starting and stopping recording, 60 FPS recording support, resolution downsampling and support for delay timer.

To install Peek in Ubuntu, you have to add a PPA repository. Run the following commands one by one to install Peek:

$ sudo add-apt-repository ppa:peek-developers/stable
$ sudo apt update
$ sudo apt install peek

Installation instructions for other Linux distributions are available here.

Gifcurry

Gifcurry is a free and open source app to convert videos into GIF files. Written in Haskell, the app comes with many additional options to customize the resulting GIF animation. Some of these options include the ability to set start and end time for the GIF, support for cropping / resizing video and putting text titles and captions. The app also comes with a command line interface if you prefer that.

Gifcurry in the form of AppImage can be downloaded from here. To save a video file into GIF using Gifcurry, you have to click on “File” button, as shown in the screenshot above.

Conclusion

Not many apps exist for creating GIF animations on Linux and even though the collection is pretty limited, these apps mentioned above gets the job done. One of the main reasons of low number of offline apps for GIF creation is the existence of numerous websites that allow you to create and edit GIF animations online. One such popular service is Ezgif which uses FFmpeg to create and modify GIF files.

About the author

Nitesh Kumar

Nitesh Kumar

I am a freelancer software developer and content writer who loves Linux, open source software and the free software community.