Flawless screen recording on Ubuntu, headless
For reasons I’m not quite ready to disclose, I’ve become interested in making the sort of screen recordings that have served Ruby on Rails so well.
Update: My project is Databinder. No screen recs yet, not quite ready for its close-up.
Update 2: Close-up accomplished.
A screen recorder is the kind of software you don’t expect to cost anything—but the people who make recorders have other ideas. The only one I’ve heard of since Lotus ScreenCam (the pioneer in this boring domain) is Snapz Pro. It’s also probably what was used for the RoR movies. It costs $70. Hmm.
Screen recorder requirements
- Work with a Gnome session on a headless Ubuntu box.
- Capture clear video that looks like the original session.
- Be free or cheap.
There is a simple screen recorder called Istanbul that one-click-installs through Synaptic, but you get what you work for with that one. Istanbul’s recordings, saved in Ogg video format, are smudged and unappealing. And with a headless box you don’t even get that because it depends on a framebuffer for capture. Ixxxx-nay.
Moving on, I thought, “Perhaps there’s some good capture freeware for my iMac so I can just rip the NoMachine client window?” Nope. And that method would be pretty lame anyway since it involves “capturing” the video several times over. Ideally, I could just intercept the NX stream, but there doesn’t seem to be anything like that. Of course, NX isn’t the only game in town…
It turns out there is a very good recorder for VNC, vnc2swf. The only problem here is that Ubuntu’s built in VNC server (Remote Desktop) doesn’t work headless, and I’d never pursued alternatives since freenx is so badass.
For headless you need the “vncserver” package. It manages its own X sessions and broadcasts them over VNC, as many sessions as you want. Unfortunately the default install is a little broken, but it’s easy to fix. Go into /usr/X11R6/lib/X11/ and delete or move the fonts directory. Then, put a softlink to /usr/share/X11/fonts/ in its place.
[Or, run a command like vncserver -fp /usr/share/X11/fonts/X11/misc/ The target font directory should have hundreds of files in it.]
Everything happens in ~/.vnc/. Try to run vncserver and it will create that directory and set up a password. When a server is running, you’ll find a .pid file in the directory. To stop server 1, run “vncserver -kill :1”. Ok. Start a server, and note the port; it should be 5901 for screen 1. Connect to it (Chicken of the VNC rules the roost on Mac) and play… you’re almost done!
Stop your VNC server, then start it with “vncserver -alwaysshared -depth 16”. You need to share it with the recorder, and of course you’ll want 16 bit color. Install the “python-pygame” package through Synaptic, then download the python version of vnc2swf. Unless you can’t spare the CPU cycles, run it on the same server you’re recording. If an X session is available it will start up with a simple interface. Connect. Record. Rejoice.
The flash format is surprisingly apt for these recordings. I tried converting some samples to h.264 in QuickTime and they only degraded in quality and bloated in size. Still, that might be handy for Google video. Gosh, I’m so excited about this surprise project, it’s like CHRISTMAS.
Anyway, check out this pristine sample recording.