This is a read-only archive. Find the latest Linux articles, documentation, and answers at the new Linux.com!

Linux.com

Feature

Screencasting with Linux

By Chad Files on March 19, 2007 (7:00:00 AM)

Share    Print    Comments   

Many times a simple screencast showing how to do something by using a series of screenshots in sequence in a video can explain what paragraph after paragraph of words cannot. Linux and a few open source applications make the job of creating such screencasts easy.

There are several ways to grab screenshots in Linux. The method that I employ here is a shell script that uses the ImageMagick import program:

#!/bin/sh

# NTSC 720x486 in columns 88x27

i=0

while [ 1 ]
do
   x=$[i+10000];
   import -frame -window $1 "cap_${x/1/}.miff"
   i=$(( $i + 1 ))
   # sleep 2s
done

This script takes one parameter, the internal ID of the window that will be captured, which you can get by running the command xwininfo -frame. The xwininfo program will give you all of the X11 information about the window/frame that you click on, but the only line you need to see is the first one, which will look something like this:

xwininfo: Window id: 0xa0348b (has no name)

This ID is what you want to pass to the shell script. Once the script starts, it will save screenshots of the window in the directory in which the script was launched. The script will run until it is interrupted by your pressing Ctrl-c. Each image is given a sequential name in the form of cap_XXXX.miff. The miff image format is ImageMagick's own format. ImageMagick can write miff images faster than any of the other supported image types, which is why we are using it here.

Making the video file

After all the screenshots have been captured, you can start putting them together in a video file. The ImageMagick convert program will combine all of the miff files into one video file. Run the command below in the directory where all of the screenshots are located:

$ convert -antialias -resize 720x486! -delay 60 *.miff capture.m2v

  • -antialias removes pixel-aliasing. This makes for a smoother-looking video.
  • -resize resizes all of the images to the specified size -- in this case, that of an NTSC video. NTSC is the standard for analog television in North America.
  • -delay tells the convert program to pause between frames, in this case for 60 hundredths of a second. This setting will have to be customized almost every time you make a screencast, because the rate you speak and the rate the screenshots are taken will almost always change with every screencast.
  • One option that I did not use but which is worth mentioning is -quality, which controls the value to use when compressing the images. The larger the number, the larger the video file and the better the quality. However, this option tends to cause overflow problems and dropped frames, and too many dropped frames will result in an unusable video.

The result of the command will be a file called capture.m2v. The m2v format is an MPEG-2 video-only stream. The next step is to add audio to the video.

Capturing audio

You can use Audacity to capture audio for the screencast. You will obviously need a microphone hooked up to your computer, and the quality of the audio will be dependent on the quality of the microphone.

To start recording, open Audacity and press the red record button in the tool bar. When you are finished, save the audio file as a WAV file (File > Export As WAV). The WAV format is uncompressed and thus the best quality.

You can record when you are creating the screen captures, or after you've put the video file together. I find it beneficial to do both. I usually create a script and read it while making the screenshots. Then I put the video together and read the script again while it is playing back. Going through the script while capturing screenshots ensures that the captures are spaced correctly. Recording the audio a second time, while watching the finished video, allows you to concentrate on the audio portion.

Combining the audio and video

The final step in creating a screencast is to bring the audio and video together. One way to do this is to use mplex, an audio/video multiplexer that is part of the MJPEG toolkit, but to do so, you first need to convert the audio file from WAV to something that mplex can use with a command like:

$ ffmpeg -i audio.wav audio.mp3

Here, FFmpeg converts the original WAV file to MP3. You could also make the conversion with Audacity.

To combine the audio and video, use the command:

$ mplex -f 3 -o final.mpg capture.m2v audio.mp3

This command tells mplex to make final.mpg out of capture.m2v and audio.mp3. The -f option tells mplex that we want a generic MPEG2-coded video file. Now, final.mpg contains a complete screencast.

An alternative way to create the final screencast is to use Kino, a non-linear video editor, which gives you the opportunity to add extra features like titles and transitions to your screencast. Using Kino also allows you to combine the screencast with other videos and filmed footage.

To get started in Kino you must convert the captured video into the DV (Digital Video) format.

$ ffmpeg -i capture.m2v -target ntsc-dv capture.dv

Here, the -target option tells ffmpeg to convert the file into an NTSC-compatible DV video.

Now you can use Kino to add the audio track. In Kino, import the DV file (File > Insert Before). To add the audio, use the FX tools (Tab bar to the right of the stage). On the Audio Transition tab, change the value to Dub. Now browse for the audio file; Kino only accepts WAV files. Use the Preview button at the bottom of the screen to see and hear what the final video will be like before it is rendered. If you like what you see, click the Render button to make the video. From here you can export the video in various formats directly from Kino.

Conclusion

As you can see, creating a screencast with Linux is relatively painless, and you can apply the process to a multitude of tasks -- provide visitors to your Web site with visual how-to help, show off an application to your friends, or create a stunning in-depth presentation for your boss.

Chad Files, a software developer from Arkansas, has been developing Web-based applications for more than 10 years, and is a contributing developer to many open source projects.

Chad Files, a software developer and writer, has been developing software applications for more than 10 years, and is a contributing developer to many open source projects.

Share    Print    Comments   

Comments

on Screencasting with Linux

Note: Comments are owned by the poster. We are not responsible for their content.

Painless?

Posted by: Anonymous Coward on March 20, 2007 02:58 AM
I'm a seasoned Linux user and administrator and have no problems understanding this article, but calling this process "relatively painless" indicates the author is just completely disconnected from reality.

#

Re:Painless?

Posted by: Anonymous Coward on March 20, 2007 03:35 AM
I agree. Although if the author had made a COMPLETE script that would do everything from recording to mplexing to converting it would be a painless process.

The moral from the story: If something is easy enough that following simple steps can get you there try to make a script for it(for the use of those people who are afraid of CLI)

#

Re:Painless?

Posted by: Anonymous Coward on March 20, 2007 07:42 AM
I agree, painless is click to start and click to stop.

#

Wink. That's painless.

Posted by: Anonymous Coward on March 20, 2007 08:12 AM
<a href="http://www.debugmode.com/wink/" title="debugmode.com">http://www.debugmode.com/wink/</a debugmode.com>

Author is considering opening his code..
Just needs a bit of influence<nobr> <wbr></nobr>;)

#

consider Pyvnc2swf as well

Posted by: Anonymous Coward on March 20, 2007 11:01 AM
Pyvnc2swf looked scary but it was actually as simple as typing:
<tt>
cd pyvnc2swf-0.9.1
recordwin.sh mymovie.swf
</tt>
then clicking on the window to record.

You end up with the mymovie.swf file as well as a mymovie.html file. Super easy. Of course, I put it into a menu entry so it's just a click away.

You can convert it to a movie instead of a flash movie, ad sound, record the entire screen etc.

Covered here..
<a href="http://applications.linux.com/article.pl?sid=06/09/18/1349218" title="linux.com">http://applications.linux.com/article.pl?sid=06/0<nobr>9<wbr></nobr> /18/1349218</a linux.com>

#

One step backward

Posted by: Anonymous Coward on March 20, 2007 11:35 AM
I actually visited this article with high hopes.
I've used the crashprone Wink and struggled through
the painfull process of syncing my audio and video with vnc2swf.

We need something as sophisticated and easy to use
as Camtasia Studio on Linux.

Cheers
Stephan

#

FFMPEG can do all that w/o... imagemagick

Posted by: Anonymous Coward on March 20, 2007 03:34 PM
FFmpeg is already capable of grabbing x11 frames directly and encode them on the fly to whatever format your PC is capable of for the framerate that has been chosen.

See:
<a href="http://ffmpeg.mplayerhq.hu/ffmpeg-doc.html#SEC4" title="mplayerhq.hu">http://ffmpeg.mplayerhq.hu/ffmpeg-doc.html#SEC4</a mplayerhq.hu>

That would be called a painless process. The described process in this article is far from being a painless program...

Other solutions exist:

  - Recording a VNC session and convert it using transcode

  - Wink

  - Istanbul

  -<nobr> <wbr></nobr>...

#

Re:FFMPEG can do all that w/o... imagemagick

Posted by: Anonymous Coward on March 21, 2007 06:36 PM
Actually, not *standard* ffmpeg. You need to patch it in order to use the x11grab option. So that's not exactly painless either.

#

Other alternatives: xvidcap and/or recordmydesktop

Posted by: Anonymous Coward on March 20, 2007 04:40 PM
Just my 2 Cents.

I've tried <a href="http://xvidcap.sourceforge.net/" title="sourceforge.net">http://xvidcap.sourceforge.net/</a sourceforge.net> Version 1.1.4 in the past and at the time I thought, that I had it all figured out, but now, that I wanted to really put it to the test, it failed on me. I simply wasn't able to produce a recording with good sound. I tried the various settings with Xvid, Quicktime, Mpeg2 output formats, but really wasn't able to produce anything satisfactory. Sound was always garbled. Xvidcap produced a pretty high system load on my configuration (old 2800+ AMD).

So, at this time my bets are on <a href="http://recordmydesktop.sourceforge.net/" title="sourceforge.net">http://recordmydesktop.sourceforge.net/</a sourceforge.net>. Worked immediately like a charm. Including native ALSA support and thereby producing very decent sound. Typical usage (recorded window is 800x600):

recordmydesktop -windowid 0x20ac4aa -fps 10 -device cmipci --on-the-fly-encoding --overwrite -delay 5

Produced out.ogg. Then two pass conversion and scaling down (Produces very good result):

ffmpeg -i out.ogg -b 384000 -s 640x480 -pass 1 -passlogfile log-file out.flv

ffmpeg -i out.ogg -b 384000 -s 640x480 -pass 2 -passlogfile log-file out.flv

flvtool2 -UP out.flv

That's it and doesn't put so much strain on the system.

#

Re:Other alternatives: xvidcap and/or recordmydesk

Posted by: Anonymous Coward on March 20, 2007 05:33 PM
Or also:

<a href="http://sourceforge.net/projects/screenkast/" title="sourceforge.net">http://sourceforge.net/projects/screenkast/</a sourceforge.net>
<a href="http://live.gnome.org/Istanbul" title="gnome.org">http://live.gnome.org/Istanbul</a gnome.org>

#

Re:Other alternatives: xvidcap and/or recordmydesk

Posted by: Administrator on March 24, 2007 09:02 PM
I second the recommendation of <a href="http://recordmydesktop.sourceforge.net/" title="sourceforge.net">recordmydesktop</a sourceforge.net>. I just used gtk-recordmydesktop to grab two quick screen recordings, and both went incredibly smoothly, simply using the default settings. There are many settings hidden away under the "Advanced" button for when you need them, but this is the first time I've ever had a screen recording go smoothly using nothing but the default settings.

Kudos to the RecordMyDesktop team!

#

suggestion

Posted by: Anonymous Coward on March 20, 2007 08:32 PM
May I suggest replacing

<tt>x=$[i+10000];

import -frame -window $1 "cap_${x/1/}.miff"</tt>

with

<tt>import -frame -window $1 "cap_$(printf "%04i" $i).miff"</tt>

#

You don't need a mic

Posted by: Administrator on March 20, 2007 02:42 PM
Audacity can record audio even if you don't have a mic, just change the device to "vol" instead of "Mic", right below the toolbar with the record/play buttons.

#

Live screencasting alternative: WebHuddle

Posted by: Administrator on March 20, 2007 10:00 PM
Thanks for the nice article! For pre-recording screencasts, I agree with the posts suggesting Wink, Istanbul or other alternatives that involve less pain.


For live screencasts, I humbly recommend WebHuddle. WebHuddle is an open source web conferencing solution that runs in any Java-enabled browser:


<a href="https://www.webhuddle.com/" title="webhuddle.com">https://www.webhuddle.com/</a webhuddle.com>


People use it on Linux, Mac, Windows, BSD, and other OSes. You can screencast your entire desktop or a limited region of it to everyone who joins your conference. The no-install client applet is an insanely small 125KB, so participants enter your meeting in seconds.


You can optionally record the live session, including audio, screencast, slides, chat and all other content. Editing is not supported yet.


Another open source web conferencing solution is the Flash-based DimDim, but it is not cross platform.

#

This story has been archived. Comments can no longer be posted.



 
Tableless layout Validate XHTML 1.0 Strict Validate CSS Powered by Xaraya