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 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:
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:
- -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:
-r 10 output.gif
- -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 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:
To record an animated GIF, run a command in the following format:
- –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:
Now to get the geometry of the focused window, run command:
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 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 apt update
$ sudo apt install peek
Installation instructions for other Linux distributions are available here.
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.
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.