Aug 1, 2007

Screencast on Linux with ffmpeg and QTRLE codec

Introduction
As we known screencasting or screencapturing on windows is very easy and pretty by using varies application e.g. Techsmith Camtasia studio,Lotus screen CAM . On linux , you have many solutions to make screencast ,e.g. Istanbul, xvidcap, yukon or ffmpeg . Using ffmpeg is the one easy way to produce screencast ,but most people usually encode output by mpeg4,flv or ogg that may not produce good quality video. Recently, I found on Clemens Fruhwirth's blog , the Screencast codec showdown elects the Animation codec as the best codec for screencasts. Animation codec is a run-length encoder also known as qtrle. Unfortunately ffmpeg, the codec library of mplayer, was only able to decode qtrle. So he wrote qtrle encoder for ffmpeg, and now it already checked in to ffmpeg's svn .

What is QTRLE
QTRLE is Apple Quicktime Animation (RLE) Format ,see http://multimedia.cx/qtrle.txt . RLE stands for Run Length Encoding. It is a lossless algorithm that only offers decent compression ratios in specific types of data. RLE compression is only efficient with files that contain lots of repetitive data like screencast that have a little change of pixels from frame to frame , see http://www.prepressure.com/library/compression_algorithms/rle .

Make ffmpeg works with qtrle codec
1. First , check your ffmpeg's formats supported.
$ ffmpeg -formats
in section ' Codecs: ' should have this :
DEV D qtrle
' E ' means that your ffmpeg can encode qtrle , you not need to compile the new one.

2. If your ffmpeg can't encode qtrle ,you must check out the svn verson of ffmpeg, then compile it .
$ ./configure --enable-gpl --enable-x11grab --enable-faad
$ make

3. To make screencast .
$ ./ffmpeg -vcodec qtrle -r 10 -g 300 -s 1024x768 -f x11grab -i :0.0 ~/Desktop/test1.mov
* Replace "-s 1024x768" with your screen resolution.
* "-r 10" sets the frame rate per second. 10fps should be enough for a screencast.
* "-g 300" sets the group size. This instructs the encoder to produce a key frame every 300 frames. With 10fps, this gives you a seekable stream point every 30 seconds.
* If your screencast is still too big, try to raise the group size, lower the frame rate and/or lower the screen resolution.

*** May the force be with you,Good Luck!!!