I've been learning about screen recording in Linux so I can make a demo/tutorial for Hooke. There seem to be a number of options (Xvidcap, recordMyDesktop, etc.), but my favorite approach is to use ffmpeg directly from the command line (If you're only interested in recording terminal sessions, look at script). You may recall ffmpeg from my earlier post about video encoding. For those to lazy to read the man page, here are some highlights:

Record audio:

$ ffmpeg -f alsa -i hw:0 out.wav

Record video:

$ ffmpeg -f x11grab -r 30 -s 1280x1024 -i :0.0 out.mpg

Record audio and video:

$ ffmpeg -f alsa -i hw:0 -f x11grab -r 30 -s svga -i :0.0 out.mpg

The trouble will be getting your audio/video captured, encoded, and stored to disk fast enough to keep up with your desired frame rate. Smaller sizes, slower frame rates, simpler encodings, and writing to ramdisks will all help with that. You can create a ramdisk with something like

$ mkdir /tmp/ramdisk
$ sudo mount -t tmpfs none /tmp/ramdisk -o size=256m

It's also possible that passing the -sameq option to ffmpeg will help, but I'm not entirely convinced.

Anything recorded or encoded by ffmpeg should be playable in mplayer (as far as I know), or you can transcode it into a format of your choice (see my video encoding post for hints.

Note to Gentoo users: you'll need to compile ffmpeg with the X flag enabled to get the x11grab video input device.

If you can't get ffmpeg to work, an example recordmydesktop command looks something like:

recordmydesktop --height 600 --width 880 --channels 1 --overwrite -o ramdisk/setup.ogv

Some benefits recordmydesktop:

  • it uses libxdamage to only monitor regions of your window that have changed (I'm not sure how ffmpeg's x11grab works).
  • it doesn't encode the video until after encoding finishes (although you can encode on the fly if you like).