Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I've seen animated GIF images of screen casts (like the one below) promoted a few times on this site as a way to improve answers.

Animated GIF image

What toolchain is being used to create these? Is there a program that does this automagically, or are people taking screencasts, converting them into a series of static frames, and then creating the GIF images?

share|improve this question
LICEcap ( is much simpler than any of the solutions below, because it's GUI-based. It's free as in freedom and price. The only downside is that you have to run it via Wine. – Dennis Jun 17 '14 at 22:56
Related: GIF screencasting; the UNIX way from the Unix & Linux Stack Exchange. – Cristian Ciupitu Oct 20 '14 at 12:37
Related: How do I convert a video to GIF using ffmpeg, with reasonable quality? on SuperUser. – Wilf Oct 17 '15 at 17:35
up vote 162 down vote accepted

First install this:

sudo apt-get install imagemagick mplayer gtk-recordmydesktop

those are the required stuff, ImageMagick, MPlayer and Desktop Recorder. Then use Desktop Recorder to capture a portion of the screen/application to use as the screencast. After the Desktop Recorder has saved the recording into an OGV video, MPlayer will be used to capture JPEG screenshots, saving them into the 'output' directory.

On a terminal:

mplayer -ao null <video file name> -vo jpeg:outdir=output

Use ImageMagick to convert the screenshots into an animated gifs.

convert output/* output.gif

you can optimize the screenshots this way:

convert output.gif -fuzz 10% -layers Optimize optimised.gif
share|improve this answer
another way to optimize gif is to use gifsicle: gifsicle -O in.gif -o out.gif I just tried and got 100x reduction in file size. – Yrogirg Mar 29 '13 at 17:37
For those wondering, the first flag in @Yrogirg command is a capital "O", not the digit "0" :) – brandizzi Jan 8 '14 at 19:51
The first convert command does not create the gif for me, it says "killed" and just terminates – ArtWorkAD Feb 10 '14 at 17:46
@ArtWorkAD See here You should adjust the amount of memory imagemagik consumes. – donovanmuller Oct 10 '14 at 10:13
I recommend combining the last two convert steps into one: convert output/* -layers Optimize output.gif. For me, this sped up processing time as well as made the output file smaller. I don't see any reason to do those steps separately. (I didn't try the -fuzz 10% argument.) – thejoshwolfe Jul 13 '15 at 18:31

Best software I ever found to record GIF screencasts is Byzanz.

Byzanz is great because it records directly to GIF, the quality and FPS is impressive while maintaining the size of the files to a minimal.


11.10 to 13.10

Unfortunately support has been dropped and you can no longer find any packages for Ubuntu that wont break your system and have missing unsatisfiable dependencies.

Fortunately Debian still maintains the package for Sid and the GIT repository still exists.

If you want to go ahead and install the .deb file from Sid (works in Ubuntu 11.10, just tested, no warranties!), download it from the Debian packages page and install it with sudo dpkg -i.

Also, one of our esteemed moderators has ported the Debian package to a PPA making it easier to install, you can add it to your system and install Byzanz by opening a terminal and typing

sudo add-apt-repository ppa:fossfreedom/byzanz
sudo apt-get update && sudo apt-get install byzanz

14.04 and above

Byzanz is now available from the universe repository

sudo apt-get install byzanz


When its installed you can run it in a terminal.

This is a small example I did just now in a vbox with

byzanz-record --duration=15 --x=200 --y=300 --width=700 --height=400 out.gif

enter image description here

share|improve this answer
I have Ubuntu 10.04 LTS and byzanz 0.1.1-4 comes with it. It's in universe/gnome repository, I found, when I typed "sudo apt-cache showsrc byzanz". I installed it and it works exactly as you demonstrate. Thanks for pointing this cool package out -- is a huge timesaver for developers to demonstrate new features to clients. – Volomike Sep 27 '12 at 19:20
Thanks, nice tool! The colours are not always accurate, but that's a minor detail. I've written a shell script which helps with capturing a window (selected on runtime by the user), posted in an answer below. – Rob W Oct 14 '12 at 15:46
Byzanz doesn't have any UI! Am I supposed to guess the x, y, width and height of the area I want to record? It's a little ridiculous that in 2014 I'd still have to do this. – Dan Dascalescu Nov 3 '14 at 23:35
@DanDascalescu No one says you need to use it... I much prefer a terminal than a GUI, what is wrong with that? – Bruno Pereira Nov 4 '14 at 8:39
@DanDascalescu There's no need to guess. You can use xwininfo to get the window properties. – Marcus Møller Jan 21 '15 at 12:53


This answer contains three shell scripts:

  1. byzanz-record-window - To select a window for recording.
  2. byzanz-record-region - To select a part of the screen for recording.
  3. A simple GUI front-end for 1, by MHC.


Thanks Bruno Pereira for introducing me to Byzanz! It's quite useful for creating GIF animations. The colours may be off in some cases, but the file size makes up for it. Example: 40 seconds, 3.7Mb.


Save one/all of the following two scripts in a folder within your $PATH. Here's an example on using the first script to make a screencast of a specific window.

  1. Run byzanz-record-window 30 -c output.gif
  2. Go to the window (alt-tab) you want to capture. Click on it.
  3. Wait 10 seconds (hard-coded in $DELAY), in which you prepare for recording.
  4. After the beep (defined in the beep function), byzanz will start.
  5. After 30 seconds (that's the meaning of 30 in step 1), byzanz ends. A beep will be broadcast again.

I included the -c flag in byzanz-record-window to illustrate that any arguments to my shell script are appended to byzanz-record itself. The -c flag tells byzanz to also icnlude the cursor in the screencast.
See man byzanz-record or byzanz-record --help for more details.



# Delay before starting

# Sound notification to let one know when recording is about to start (and ends)
beep() {
    paplay /usr/share/sounds/KDE-Im-Irc-Event.ogg &

# Duration and output file
if [ $# -gt 0 ]; then
    echo Default recording duration 10s to /tmp/recorded.gif
    D="--duration=10 /tmp/recorded.gif"
read X <<< $(awk -F: '/Absolute upper-left X/{print $2}' <<< "$XWININFO")
read Y <<< $(awk -F: '/Absolute upper-left Y/{print $2}' <<< "$XWININFO")
read W <<< $(awk -F: '/Width/{print $2}' <<< "$XWININFO")
read H <<< $(awk -F: '/Height/{print $2}' <<< "$XWININFO")

echo Delaying $DELAY seconds. After that, byzanz will start
for (( i=$DELAY; i>0; --i )) ; do
    echo $i
    sleep 1

byzanz-record --verbose --delay=0 --x=$X --y=$Y --width=$W --height=$H $D


Dependency: xrectsel from xrectsel. Clone the repository and run make to get the executable. (If it protests there is no makefile, run ./bootstrap and the ./configure before running `make).


# Delay before starting

# Sound notification to let one know when recording is about to start (and ends)
beep() {
    paplay /usr/share/sounds/KDE-Im-Irc-Event.ogg &

# Duration and output file
if [ $# -gt 0 ]; then
    echo Default recording duration 10s to /tmp/recorded.gif
    D="--duration=10 /tmp/recorded.gif"

# xrectsel from
ARGUMENTS=$(xrectsel "--x=%x --y=%y --width=%w --height=%h") || exit -1

echo Delaying $DELAY seconds. After that, byzanz will start
for (( i=$DELAY; i>0; --i )) ; do
    echo $i
    sleep 1
byzanz-record --verbose --delay=0 ${ARGUMENTS} $D

Gui version of byzanz-record-window

(comment by MHC): I've taken the liberty to modify the script with a simple GUI dialogue


# AUTHOR:   (c) Rob W 2012, modified by MHC (
# NAME:     GIFRecord 0.1
# DESCRIPTION:  A script to record GIF screencasts.
# DEPENDENCIES:   byzanz,gdialog,notify-send (install via sudo add-apt-repository ppa:fossfreedom/byzanz; sudo apt-get update && sudo apt-get install byzanz gdialog notify-osd)

# Time and date
TIME=$(date +"%Y-%m-%d_%H%M%S")

# Delay before starting

# Standard screencast folder

# Default recording duration

# Sound notification to let one know when recording is about to start (and ends)
beep() {
    paplay /usr/share/sounds/freedesktop/stereo/message-new-instant.oga &

# Custom recording duration as set by user
USERDUR=$(gdialog --title "Duration?" --inputbox "Please enter the screencast duration in seconds" 200 100 2>&1)

# Duration and output file
if [ $USERDUR -gt 0 ]; then

# Window geometry
read X < <(awk -F: '/Absolute upper-left X/{print $2}' <<< "$XWININFO")
read Y < <(awk -F: '/Absolute upper-left Y/{print $2}' <<< "$XWININFO")
read W < <(awk -F: '/Width/{print $2}' <<< "$XWININFO")
read H < <(awk -F: '/Height/{print $2}' <<< "$XWININFO")

# Notify the user of recording time and delay
notify-send "GIFRecorder" "Recording duration set to $D seconds. Recording will start in $DELAY seconds."

#Actual recording
sleep $DELAY
byzanz-record -c --verbose --delay=0 --duration=$D --x=$X --y=$Y --width=$W --height=$H "$FOLDER/GIFrecord_$TIME.gif"

# Notify the user of end of recording.
notify-send "GIFRecorder" "Screencast saved to $FOLDER/GIFrecord_$TIME.gif"
share|improve this answer
Are these scripts kept someplace like github? They're super useful, it'd be nice if they were kept someplace better than text in StackOverflow answer. – KFro Jul 3 '14 at 22:30
@KFro This is Ask Ubuntu, not SO ;) No, I haven't put them in a git repository, because the scripts themselves are badly documented (for users). The accompanying documentation is included with the answer, so I see no benefit of splitting up the files and documentation in a Git repository. – Rob W Jul 4 '14 at 7:43
Note that xrectsel has been separated from FFcast2; it is now and independent repository at – Rmano Nov 4 '14 at 16:05
No more credits for editing, but done ;-). – Rmano Nov 4 '14 at 16:15
Just wanted to say a huge thanks for this - awesome answer and helped me out a lot. Here's what I ended up with. I like to use notify-send as well in case my sound is off. – Daniel Buckmaster Sep 10 '15 at 2:20

ffmpeg Install ffmpeg

One of the best tools I use is ffmpeg. It can take most video from a screencast tool such as kazam and convert it to another format.

Install this from software-center - it is automatically installed if you install the excellent ubuntu-restricted-extras package.

Kazam can output in the video formats mp4 or webm. Generally you get better results outputting in mp4 format.

example GIF making syntax

The basic syntax to convert video to gif is:

ffmpeg -i [inputvideo_filename] -pix_fmt rgb24 [output.gif]

GIFs converted - especially those with a standard 25/29 frame-per-second can be very large. For example - a 800Kb webm 15-second video at 25fps can output to 435Mb!

You can reduce this by a number of methods:


Use the option -r [frame-per-second]

for example ffmpeg -i Untitled_Screencast.webm -r 1 -pix_fmt rgb24 out.gif

Size reduced from 435Mb to 19Mb

file-size limit

Use the option -fs [filesize]

for example ffmpeg -i Untitled_Screencast.webm -fs 5000k -pix_fmt rgb24 out.gif

Note - this is an approximate output file size so the size can be slightly bigger than specified.

size of output video

Use the option -s [widthxheight]

for example ffmpeg -i Untitled_Screencast.webm -s 320x200 -pix_fmt rgb24 out.gif

This reduced the example 1366x768 video size down to 26Mb

loop forever

Sometimes you might want the GIF to loop forever.

Use the option -loop_output 0

ffmpeg -i Untitled_Screencast.webm -loop_output 0 -pix_fmt rgb24 out.gif

further optimise and shrink

if you use imagemagick convert with a fuzz factor between 3% and 10% then you can dramatically reduce the image size

convert output.gif -fuzz 3% -layers Optimize finalgif.gif


combine some of these options to reduce to something manageable for Ask Ubuntu.

ffmpeg -i Untitled_Screencast.webm -loop_output 0 -r 5 -s 320x200 -pix_fmt rgb24 out.gif

followed by

convert output.gif -fuzz 8% -layers Optimize finalgif.gif


enter image description here

share|improve this answer
If you have Docker and your video is demo.mkv you can run this commands: docker run --rm -v $(pwd):/tmp/video/ jrottenberg/ffmpeg -i /tmp/video/demo.mkv -framerate 1/2 -pix_fmt rgb24 -loop 0 /tmp/video/demo.gif, sudo chown $USER:$USER demo.gif – czerasz Dec 13 '15 at 0:35
To me it complains that there is no such option as -loop_output... – Paranoid Panda Mar 14 at 16:52
+1 Best answer. But one q do you still think ubuntu-restricted-extras is excellent ?? – Severus Tux May 22 at 14:48


Silentcast is another great gui based tool for creating animated .gif images. Its features include:

  • 4 recording modes:

    1. Entire screen

    2. Inside window

    3. Window with decoration

    4. Custom selection

  • 3 output formats:

    1. .gif

    2. .mp4

    3. .webm

    4. .png (frames)

    5. .mkv

  • No installation necessary (portable)

  • Custom working directory

  • Custom fps


If you want a regular installation and are running a supported version of Ubuntu you can install Silentcast by PPA:

sudo add-apt-repository ppa:sethj/silentcast  
sudo apt-get update  
sudo apt-get install silentcast  

If you aren't running a supported version of Ubuntu (you should really upgrade!) you will need to download the latest version from the GitHub page and manually satisfy the dependencies (you can procure yad and ffmpeg from here and here respectively) or, if you are running a slightly more recent version such as 13.10 you could try downloading the .deb directly.

If you're using Gnome you might want to install the Topicons extension to make stopping Silentcast easier.


Start Silentcast from your desktop environment's gui or run the silentcast command in a terminal. Pick your settings and follow the on-screen prompts. When you're done recording you will be presented with a dialog for optimizing the final output by removing a certain number of frames.

For more in depth usage guidelines take a look at the README, either the online GitHub version or the local version stored in /usr/share/doc/silentcast with zless or your favourite editor.



Silentcast is still in the development stage and although it is quite stable you might encounter some bugs. If you do please report them on the project's GitHub issues tracker. If you have trouble installing from the PPA and are running a supported version of Ubuntu leave a comment below or contact the maintainer (me) on Launchpad.

share|improve this answer
as soon as I hit 'Stop' it crashes... – Francisco Corrales Morales Nov 18 '14 at 2:35
@FranciscoCorralesMorales Can you run it from the command-line and then try? Once it crashes take the output and upload it to and link it back here so I can take a look. Thanks! – Seth Nov 18 '14 at 2:35
used this and it worked wonderfully. thanks! – JimB Apr 27 at 10:46

There are all sorts of complicated and well-working (presumably) ways to do this listed here. However, I've never wanted to go through that process before nor since. So, I simply use an online converter which suits my needs the few times I need to do so. I've used this site:

It's not my site and I'm not affiliated with them in any way. They're just the one in my bookmarks and there are many more.

share|improve this answer

If you want to get even fancier, you can use a more sophisticated method than animated gifs using HTMl5 canvas screencasting. The x11-canvas-screencast project will create an html5 canvas animated screen capture.

You may have seen some famous examples of this tech on the Sublime Text website. x11-canvas-screencast takes this method a step further by incorporating tracking of the mouse cursor. Here's a demo of what x11-canvas-screencast produces

The result is better than an animated gif since it's not limited to the number of colors it has and it takes less bandwidth.

share|improve this answer

protected by Community Aug 1 '13 at 9:23

Thank you for your interest in this question. Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site.

Would you like to answer one of these unanswered questions instead?

Not the answer you're looking for? Browse other questions tagged or ask your own question.