How to Make Gif Animations from Screencasts on Ubuntu

How to Make Gif Animations from Screencasts on Ubuntu

Last updated:
Table of Contents

Last tested on Ubuntu 20.04

TL;DR: 1) Record mp4 video with Kazam 2) Convert video to gif using Gifify

In order to make gif animations on Ubuntu, you need to first record a screencast (using Kazam) and then using Gifify to convert the video into a gif.

There as the steps:

1) Install Kazam and Record Screencast

Use a small frame-rate to keep file size small (10 is enough)

  • 1) Install $ sudo apt install kazam

  • 2) Set frame-rate for screencassts in Kazam

set-kazam-frame-rate The lower the frame rate, the
smaller the gif file.
10 is enough.

  • 2) Start recording a screencast

    kazam-recording-screencast Click to start recording a screencast

  • 3) When finished, click the camcorder icon2 on the task bar:

    camcorder-icon Click the camcorder icon
    when you're done recording

  • 4 Click again on Kazam to save if needed.

    kazam-icon-on-taskbard Open up the dialog and save
    the video you just recorded.

2) Install gifsicle

Gifsicle is needed by gifify

$ git clone git@github.com:kohler/gifsicle.git
$ cd gifsicle
$ autoreconf -i
$ ./configure
$ make && sudo make install

3) Install Gifify

Install Gifify using npm1

$ sudo npm i gifify -g

I'm using version 2.4.3:

$ gifify --version
2.4.3

4) Install ffmpeg

Install the ffmpeg package:

$ sudo apt install ffmpeg

5) Install ImageMagick

Install the imagemagick package:

$ sudo apt install imagemagick

6) Convert the mp4 video into a GIF file using Gifify

This uses a lot of RAM, even for smallish video files.

Example: convert a file called video.mp4 to video.gif

There's all sorts of options to control the frame-rate and other things too.

$ gifify video.mp4 -o video.gif

meta-capturing Gifify being used to turn an MP4 screencast into a GIF file

Troubleshooting

convert-im6.q16: cache resources exhausted

This strategy is quite resource-intensive and the default memory limit is quite small (256MB)

As per this Github Issue, open up file /etc/ImageMagick-6/policy.xml and change the line where it says 256MiB (should be around line 60) and set it to something higher depending on your system resources, for example, 4GiB as below.

<policy domain="resource" name="memory" value="4GiB"/>

Maximum call stack size exceeded

You forgot to install imagemagick?


1: NPM stands for Node Package Manager. It's used to manage dependencies for NodeJS. You can install it on Ubuntu with $ sudo apt install npm

2: You can also stop the recording typing Super + Ctrl + f. P.S.: Super is the Windows logo key.


References