Create training videos with pyvnc2swf

103

Author: Paul Virijevich

How many times has someone verbally explained how to do something on a computer to you? How many times do you end up asking them to just show you? For these situations there is pyvnc2swf, a program that turns screen input into video files. Let’s see just how easy it is to use it to producing training videos.

Vnc2swf comes in two versions. The older C version is outdated and not recommended. The newer Python version, pyvnc2swf, is the one to install. I installed pyvnc2swf on openSUSE 10.0, but the same download works on any platform with Python and pygame. Pyvnc2swf also requires a VNC server; you can use TightVNC, RealVNC, or UltraVNC, to name a few.

There is not much to getting pyvnc2swf up and running. A tarball is available for use on any system that supports Python — Linux, Mac OS X, and Windows included. Once you’ve installed the prerequisite software, use the usual tar -zxvf pyvnc2swf-0.8.2.tar.gz to unpack the archive. You will see a directory named pyvnc2swf-0.8.2. To start pyvnc2swf, go into the newly created directory and run the script vnc2swf.py. This pops up a window with the hostname and port for pyvnc2swf to connect to. You can connect to your local host, in which case the default localhost:5900 is correct.

Once pyvnc2swf starts up, click on the Save As box and choose a name for the recording. There are three file types you can choose to save as: shape, video and VNCRec. According to the documentation, shape seems to be the preferred video format, because it is the most compatible with older versions of Flash. The video format produces the smallest size videos, but they work only with Flash 7 and up. You can convert from shape to video format later. This creates a smaller video that is compatible with older versions of Flash. VNCRec uses an older format for recording VNC sessions that is not Flash-compatible.

In practice you should be fine with the video format, but I’m going to use shape for now so we can explore using pyvnc2swf’s editor.

Click Start to begin recording all of the windows on your screen. A one-minute test recording I made took up 376KB of disk space in shape format.

Pyvnc2swf provides two ways to view video. The first is by using the play.py script to play back the file. You can use this method regardless of whether you have Flash player installed.

Pyvnc2swf can also create a Web page with the Flash video embedded in it. My only problem with it is that the default behavior loops the video over and over again. To change this, edit the HTML file and change both instances of loop="True" to loop="False".

Make mine multimedia

Now that we’ve successfully captured some video, let’s add some sound to it. For testing purposes, you can use any MP3 file; MP3 is the only supported audio format. If you want to add narration, hook up a microphone and record using your desktop environment’s sound recorder, or Audacity. The advantage of using Audacity is that it both records and edits sound files.

Once you have an audio file, use the command:

./edit.py -o soundtest.swf -a sound.mp3 test.swf

This creates the Flash video soundtest.swf by adding the audio from the MP3 file sound.mp3 to the original test.swf video. Once again, pyvnc2swf creates a sample Web page for you. Load soundtest.html into your browser and you should see and hear your video.

Now let’s convert our completed file from shape to the video format and see what we gain in compression. A video I recorded demonstrating Vino, GNOME’s desktop sharing tool, was 10 seconds long and 192KB in size. Adding 10 seconds of audio brought that up to 384KB. Converting to video format with the command:

edit.py -o final.swf -c -t video soundtest.swf

gave me a final file size of 328KB, or a little more than 15% reduction. I did not notice any degradation in quality with the compressed video.

One last editing trick is the ability to resize how large videos will be when output to the screen. If you want to make a copy of your video that takes up only 75% of the screen real estate of the original, use the command:

./edit.py -o soundtest_resize.swf -s 0.75 soundtest.swf

The resulting video will be 75% the size of the original.

Being selective

Capturing the entire desktop is not very useful when you’re demonstrating only a specific application. Fortunately, pyvnc2swf offers the script recordwin.sh to record just a single window. Run the script with the name of the video you want to create as the argument and keep an eye on your cursor. For example:

./recordwin.sh single_win.swf

Once the cursor turns into a cross, click on any window, and pyvnc2swf will start recording it. To stop recording, go to the terminal where you launched pyvnc2swf and Press Ctrl-c. Pyvnc2swf creates the file single_win.html with the video embedded for browser playback. The recordwin script does not use compression by default. In my testing, a one-minute single window capture took up 645KB of disk space. After compressing the file, I got it down to 425KB.

If you do not want to produce Flash videos, pyvnc2swf claims to be able to convert files to MPEG. This feature requires you to have pymedia installed. I was unable to get this working, however. Pyvnc2swf threw out some error messages that were not helpful.

For quickly developing training videos, pyvnc2swf is hard to beat. The resulting videos are of reasonable size and good quality. The only problem I encountered was converting to MPEG.

Once you have pyvnc2swf working, you can show people instead of telling them, and if they need to see something again, they can just go to a Web page.