How to record screencasts as GIFs on Ubuntu/Linux
16 Dec 2013by Guilherme Berger
A screencast says more than a thousand pictures. That’s why I like to record my screen as a GIF when I want to demonstrate a new feature or experiment I’m working on.
The core of the method consists of using Byzanz to record your screen as a GIF. First, to install it, you should run:
Then, you can use this command to save a recording of a portion of your screen to a file in the current directory:
Improving the method
Two problems arise: how to know the coordinates you want to use for the recording, and how to know how much time is left.
To get information about the screen coordinates, you could use xdotool to
track your mouse position. First, install it (sudo apt-get install xdotool
).
Then, run this snippet:
Now this terminal screen will show live information about your mouse position. Use this to get your x, y, width and height parameters for byzanz-record.
This bash function displays a running countdown:
By using it along the byzanz-record command, we can have a live countdown of the
time remaining on our recording. The sleep 1
part is important because the recording
tool has a default delay of one second before starting. (You can use the --delay=X
parameter to modify this).
Naturally, after the terminal loses focus you will not be able to see the timer anymore. However, if you set this terminal window to always be on top and move it away from the action, you can go along your demonstration and still keep track of the time remaining.