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

Linux.com

Feature

Create training videos with pyvnc2swf

By Paul Virijevich on September 22, 2006 (8:00:00 AM)

Share    Print    Comments   

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.

Share    Print    Comments   

Comments

on Create training videos with pyvnc2swf

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

Proprietary

Posted by: Anonymous Coward on September 22, 2006 11:27 PM
Flash is proprietary software.
My mom says that proprietary software is the devil!

#

xorg/ImageMagick/mencoder hack for scrncap to xv

Posted by: Anonymous Coward on September 23, 2006 12:56 AM
xvidcap was one of the best I've seen for this but it isn't well maintained and doesn't currently work for me ffmpeg mutated too much. I've gotten some mileage out of something like:

xwinid=`xwininfo|grep "Window id:"|awk '{print $4}'`

while [ 1=1 ]
do

    nowtime=`date +%Y%m%d%H%M%S%N`

    xwd -id $xwinid |gzip -1 > screencap.$nowtime.xwd.gz
done

gunzip *.xwd.gz
mogrify -format jpmencoder "mf://*.$in_type" -mf fps=$outfps -o amovie.xvid -ovc xvid -xvidencopts bitrate=2400 #-oac mp3lame -lameopts cbr:br=128g *.xwd

A bit of a hassle post processing to convert the frames to a movie but i get about 3-5fps on a AMD-64 3100

#

Re:xorg/ImageMagick/mencoder hack for scrncap to x

Posted by: Anonymous Coward on September 23, 2006 12:58 AM
Ooops corrected version
xvidcap was one of the best I've seen for this but it isn't well maintained and doesn't currently work for me ffmpeg mutated too much. I've gotten some mileage out of something like:

xwinid=`xwininfo|grep "Window id:"|awk '{print $4}'`

while [ 1=1 ]
do

        nowtime=`date +%Y%m%d%H%M%S%N`

        xwd -id $xwinid |gzip -1 > screencap.$nowtime.xwd.gz
done

gunzip *.xwd.gz
mogrify -format jpg *.xwd

mencoder "mf://*.jpg" -mf fps=6 -o amovie.xvid -ovc xvid -xvidencopts bitrate=2400 #-oac mp3lame -lameopts cbr:br=128g *.xwd

A bit of a hassle post processing to convert the frames to a movie but i get about 3-5fps on a AMD-64 3100

#

Re:xorg/ImageMagick/mencoder hack for scrncap to x

Posted by: Administrator on October 08, 2006 02:00 PM
Interesting, but does this method use a lot of resources?

#

Ubuntu Dapper

Posted by: Anonymous Coward on September 26, 2006 07:00 PM
I have found that pyvnc2swf crashes in Ubuntu Dapper, and I think it is because of the version of PyGame. This is simple to fix though: Install Breezy into a folder using debootstrap, use chroot to enter that installation, install PyGame, etc., run "export DISPLAY=localhost:0" to set the display (you may need to run a different display to let the Breezy system have access, for example with "Xnest -ac<nobr> <wbr></nobr>:50" then use localhost:50 instead) then just run pyvnc2swf with your VNC server running.

#

Re:pyvnc2swf compatible with vino?

Posted by: Anonymous Coward on October 12, 2006 12:13 AM
It works but you will need to pass special paramters and it will take up more space, since the default way of capturing the mouse doesn't work under vino

#

pyvnc2swf compatible with vino?

Posted by: Administrator on October 08, 2006 01:57 PM
... is what I wonder.

I would like to record the desktop on<nobr> <wbr></nobr>:0 and since vino is already running there, it would be preferable if pyvnc2swf also works with Vino. Do you know anything about the matter? Google seem not to...

#

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



 
Tableless layout Validate XHTML 1.0 Strict Validate CSS Powered by Xaraya