Record Screen as Animated GIF in Ubuntu with Byzanz

Spread the love

We have previously shown you how to record your screen as an animated GIF in Windows and Mac OS X, but what about Linux? If you are a Linux user and are looking for ways to record your screen as an animated GIF, byzanz is the app for you.

Byzanz is a simple command line tool to record a running X desktop to an animation suitable for presentation in a web browser, which in this case, refers to an animated GIF. While the support and development stopped years ago, the current version is still working well on Ubuntu 14.10.

Installation

For Ubuntu 14.04 and above, Byzanz is available in the Universe Repository. To install, simply search for it in Ubuntu Software Center,or use the command:

sudo apt-get install byzanz

For Fedora, you can use the command:

sudo yum install byzanz

Usage

The command to use Byzanz is byzanz-record. To get started, open a terminal and type:

byzanz-record -d DURATION --delay=DELAY -x X-COORDINATE -y Y-COORDINATE -w WIDTH -h HEIGHT FILENAME

The texts in uppercase are the options that you need to change. Change the DURATION to the length of time to record the animation. The DELAY option is optional, and when set will delay for the specified time before the recording starts. The X-COORDINATE and Y-COORDINATE refer to the location on the screen for it to start capturing and the WIDTH and HEIGHT is the size of the recording. For example, to record the whole desktop for 10 seconds with a 5 second delay, use the command:

byzanz-record -d 10 --delay=5 -x 0 -y 0 -w 1440 -h 900 desktop-animation.gif

Note: you can add the -v flag to get it to display the progress of the recording.

Extending Byzanz

By default, you will need to specify the coordinates of the recording area and the width and height for byzanz to work. Won’t it be great if there is a GUI tool that you can use to record a window? Here is the bash script that you can use as a GUI for Byzanz.

Open a text editor and paste the following code to it:

#!/bin/bash
 
# AUTHOR:   (c) Rob W 2012, modified by MHC (http://askubuntu.com/users/81372/mhc)
# NAME:     GIFRecord 0.1
# DESCRIPTION:  A script to record GIF screencasts.
# LICENSE:  GNU GPL v3 (http://www.gnu.org/licenses/gpl.html)
# 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
DELAY=10
 
# Standard screencast folder
FOLDER="$HOME/Pictures"
 
# Default recording duration
DEFDUR=10
 
# 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
    D=$USERDUR
else
    D=$DEFDUR
fi
 
# Window geometry
XWININFO=$(xwininfo)
read X 
 
Save the script as "byzanz-gui" (or any other name that you prefer) to your Home folder without any extension. 
 
Next, grant the script executable permission:
 
<pre class="bash">chmod +x byzanz-gui

Lastly, execute the script:

./byzanz-gui

In the window that pops up, enter the duration for the recording and click OK.

You will notice that your mouse cursor has become a crosshair. Click on the window that you want to record. It will start the recording with a 10 second delay.

You can find the animated GIF in your Pictures folder.

There is also another script that allows you to capture a region instead of a window. However, for that to work, it requires xrectsel which you have to download, compile and install manually. For that, we won’t cover the script in this tutorial.

Conclusion

Byzanz is not the only tool that can record your screen as an animated GIF, but it is one that can do the job well. While it doesn’t come with a beautiful user interface like other screen recording tools for Windows and Mac, being a command line tool gives it the benefit of customizability and can be easily extended with simple bash script.

Subscribe to our newsletter!

Our latest tutorials delivered straight to your inbox

Sign up for all newsletters.
By signing up, you agree to our Privacy Policy and European users agree to the data transfer policy. We will not share your data and you can unsubscribe at any time. Subscribe


Damien Oh

Damien Oh started writing tech articles since 2007 and has over 10 years of experience in the tech industry. He is proficient in Windows, Linux, Mac, Android and iOS, and worked as a part time WordPress Developer. He is currently the owner and Editor-in-Chief of Make Tech Easier.

Comments (4)