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