gallery.py: Rework headers to use an OrderedDict
[blog.git] / posts / Screen_recording.mdwn
1 I've been learning about screen recording in Linux so I can make a
2 demo/tutorial for [[Hooke]].  There seem to be a number of options
3 ([Xvidcap][], [recordMyDesktop][], etc.), but my favorite approach is
4 to use [ffmpeg][] directly from the command line (If you're only
5 interested in recording terminal sessions, look at [[script]]).  You
6 may recall ffmpeg from my earlier post about [[video encoding|video]].
7 For those to lazy to read the man page, here are some highlights:
8
9 Record audio:
10
11     $ ffmpeg -f alsa -i hw:0 out.wav
12
13 Record video:
14
15     $ ffmpeg -f x11grab -r 30 -s 1280x1024 -i :0.0 out.mpg
16
17 Record audio and video:
18
19     $ ffmpeg -f alsa -i hw:0 -f x11grab -r 30 -s svga -i :0.0 out.mpg
20
21 The trouble will be getting your audio/video captured, encoded, and
22 stored to disk fast enough to keep up with your desired frame rate.
23 Smaller sizes, slower frame rates, simpler encodings, and writing to
24 ramdisks will all help with that.  You can create a ramdisk with
25 something like
26
27     $ mkdir /tmp/ramdisk
28     $ sudo mount -t tmpfs none /tmp/ramdisk -o size=256m
29
30 It's also possible that passing the `-sameq` option to ffmpeg will
31 help, but I'm not entirely convinced.
32
33 Anything recorded or encoded by ffmpeg should be playable in mplayer
34 (as far as I know), or you can transcode it into a format of your
35 choice (see my [[video encoding|video]] post for hints.
36
37 Note to Gentoo users: you'll need to compile ffmpeg with the `X` flag
38 enabled to get the x11grab video input device.
39
40 If you can't get ffmpeg to work, an example `recordmydesktop` command
41 looks something like:
42
43     recordmydesktop --height 600 --width 880 --channels 1 --overwrite -o ramdisk/setup.ogv
44
45 Some benefits recordmydesktop:
46
47 * it uses `libxdamage` to only monitor regions of your window that
48   have changed (I'm not sure how ffmpeg's x11grab works).
49 * it doesn't encode the video until after encoding finishes (although
50   you can encode on the fly if you like).
51
52 [Xvidcap]: http://xvidcap.sourceforge.net/
53 [recordMyDesktop]: http://recordmydesktop.sourceforge.net/
54 [ffmpeg]: http://www.ffmpeg.org/
55
56 [[!tag tags/linux]]