Archive

Recording VNC

Using VNC is a great way to make movies of a desktop session. It’s possible to record a desktop session from any operating system that runs a VNC server, including Linux, Windows and the BSDs. These could be for demonstration, training purposes or advertising. Once the recording has been made, it can be converted to a standard video file using transcode, ready for distribution.

Installing

  • Download the vncrec source code from the website.

  • You will need the following packages and their dependencies installed to compile vncrec: build-essential libxmu-headers libxt-dev libxaw-headers libxaw7-dev libxvidcore

  • Follow the instructions on the website for compiling the software. These, briefly, are:
$ xmkmf -a $ cd libvncauth; make $ cd ../vncrec; make
  • On Ubuntu Breezy, some errors in configuration and compilation are seen. However these don’t appear to affect the production of a working binary.
  • vncrec needs to be in the system path in order for the later transcode steps to work, so copy the binary to /usr/local/bin/:

$ cp vncrec /usr/local/bin/
  • You may need to run the previous command as root if you do not have write permissions on /usr/local/bin/

  • You will need to have the vncserver package (or one of the variants, such as tightvncserver) installed on the machine of which you will be recording the desktop.

  • You will need to have the vncviewer package (or one of the variants, such as tightvncviewer) installed on the machine on which you want to make the recording. (This can be the same machine as the system on which vncserver will be run.)

  • You will need to have the transcode package installed.

  • All of the above packages should be in your distribution’s repositories. With Ubuntu, you will need to have the universe and multiverse repositories enabled.

Recording

  • Start a VNC server instance on the host you want to record on:
$ vncserver   New 'X' desktop is george:1  Starting applications specified in /home/tony/.vnc/xsession Log file is /home/tony/.vnc/george:1.log
  • Think about the resolution of the screen where you plan to play this video back. You might want to specify a resolution for the vncserver which is just less than that of the target machine. That way someone watching your video will be able to see it all on screen at once. For example, if most people run their desktop at 800×600 then you might want to set your vncserver up to be running at 720×576 or some other roughly 4:3 or 16:9 ratio resolution. Be careful about resolutions though – some applications are only usable at 1024×768 or higher.
  • You may also want to set the colour depth.
 $ vncserver -geometry 720x576 -depth 8
  • Connect to the VNC server using:
vncrec -record sample.vnc
  • Recording will start as soon as you connect to the server. You can also specify the hostname and the “desktop number” to connect to on the command line:
vncrec -record sample.vnc 192.168.0.130:1
  • If you do not specify a remote host, the standard VNC dialog boxes will appear prior to connection to allow you to supply a hostname or IP address.
  • When connecting to a Windows VNC server you might have to use the -truecolour option to produce a recording that transcode can use.

  • Make sure the mouse movements and text entered into applications are on screen long enough for the viewer to catch them. If you are a regular computer user and a fluent typist, try to work at half your normal rate.
  • Remember to stop the VNC server after you’ve finished your recording:
vncserver -kill :1

Playing back

  • Play back your recorded file:
vncrec -play sample.vnc

Transcoding

  • Transcode the recording to a .avi file using:

transcode -x vnc --use_rgb -i file.vnc -o file.avi -y xvid -k --dvd_access_delay 5 -f 10
  • -x defines the input module used, in this case the VNC module.

  • –use_rgb seems to be the crucial option. Many pages on this subject omit it, yet all our tests required the option to be present for the transcoding process to work properly.

  • -i defines the input file – the VNC recording.

  • -o defines the output file – the .avi file.

  • -y defines the codec used for the video, in this case Xvid.

  • -k tells transcode to swap the red and blue in the video frames. This appears to be necessary for VNC recordings.

  • -f 10 is the frame rate (per second)

  • —dvd_access_delay 5 drops some frames from the start of the recording (5 seconds-worth in this example). This gets around bad frames that occur as the vncserver gets up to speed.

  • Additonal options are available during the transcode. Of particular interest in this scenario might be:
    • -g defines the size of the input video, e.g. -g 800×600. This is reported to be necessary in some cases where the detected resolution is not correct.

    • -Z defines the resolution of the output video, e.g. -Z 720×480. This can be used to resize the output video, but be careful not to render any on-screen text unreadable by reducing the size too far.

  • The transcoding process is quite slow. You should see output similar to the following during the process:
printing frame for time = 28.900000 seconds, EMT: 0:00:28, ( 0| 0| 0)  printing frame for time = 29.000000 seconds, EMT: 0:00:28, ( 0| 0| 0)  printing frame for time = 29.100000 seconds, EMT: 0:00:29, ( 0| 0| 0)  printing frame for time = 29.200000 seconds, EMT: 0:00:29, ( 0| 0| 0) 
  • The process is so slow because each frame has to be decoded from the VNC format, undergo any other transcoding processes, e.g. resizing, then be re-encoded in the output format. Transcoding a 30 second VNC recording took about 30 minutes on a 1.4GHz Pentium M system.
  • Tips:
    • transcode can appear to hang at the end of encoding (i.e. the printing frame messages have reached the duration of the original recording) with the message [[ShmCleanup]] called but it still using 100% CPU time. Playback the recording and if it has all been encoded, kill transcode with a Ctrl+C.

    • Don’t try to play back the output file whilst it is still being transcoded. This appears to cause transcode to exit sometimes.

    • On Ubuntu, the transcoding process seems to produce a lot of these messages:
[tcxpm2rgb.c:334] truncated 16 characters [tcxpm2rgb.c:334] truncated 16 characters
  • These don’t seem to affect the process though.
    • There seem to be some problems transcoding on an AMD64 system (tested under Ubuntu). The output video is, well, pants. It has lots of blue lines vertically up it and is unwatchable. Removing the -k option results in watchable video, but the colours are all wrong!

  • Test the output file using your favourite media playing application, for example:
$ xine file.avi

External Links

Leave a Reply