Monday, September 24, 2012

How to Record Screencasts as Animated GIFs under Ubuntu 12.10/12.04/11.10/Linux Mint 13

A screencast is the recording of computer screen (aka screen capture) with the help of screen recording software. If you want to convert these screencasts into animated GIFs to use them on your blog or website, then this tutorial will explain this using two methods under Ubuntu/Linux Mint.

Method 1

The first method consists of using Byzanz which allows to record screencasts as GIFs. To install it under Ubuntu 12.10/12.04/11.10 or Linux Mint 13/12, open the terminal and run these commands:

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

You can now use this comman to record GIF screencasts (replace details with your own):

byzanz-record --duration=15 --x=400 --y=400 --width=800 --height=600 output.gif

For more help about the use of Byzanz, run this command:

byzanz-record --help

Note: The GIF file will be saved in the current terminal location.
Method 2

The second method is a little bit complicated because we will use a screen capturing tool to record a screencast, convert this video to images (JPG), then converting these images to an animated GIF. Let's firstly install needed packages with this command:

sudo apt-get install imagemagick gtk-recordmydesktop mplayer

Start now the recordMyDesktop application and record a screencast, then save it in any folder of your choice (.ogv format).

Let's now save this video in JPG screenshots with this command:

mplayer -ao null video.ogv -vo jpeg:outdir=mypics

video.ogv -> Replace it with your own video file name.
mypics -> This is the name of the folder that will contain the extracted JPEG files. Rename it to whatever you want.

Using the terminal, cd to the folder containing JPEG screenshots and run this command:

convert * file.gif

If you have extracted the JPEG files in a folder containing various file formats, then run this command instead:

convert *.jpg file.gif

Rename file.gif with any name of your choice. The conversion may take time depending on the total size of JPEG files.

To optimize this GIF file, you can use this command:

convert file.gif -fuzz 15% -layers Optimize file-optimized.gif