12 June, 2009

Screen Capture with FFmpeg

Sometimes it's useful to capture the display output as a means of archiving a procedure or to demonstrate a user experience. The following command will capture the display region 1680x1050 at 30fps for 90 seconds and shrink it to a 640x480 video at near raw resolution (fixed quantizer scale of 1).

The important thing is to confirm your ffmpeg format supports x11grab, otherwise you'll get the following error:

Unknown input or output format: x11grab



ffmpeg -y -f x11grab -r 30 -s 1680x1050 -i :0.0 -t 90 -qscale 1 -s 640x480 out.mpg


As you can imagine, capturing 30fps adds significant resource loading, if you so choose you can down-sample the frame rate but you may need to use an alternative encoder for non-compliant frame rates of some codecs.

The MJPEG encoder seems to work well enough for slow frame rates, like 1 Hz.


ffmpeg -y -f x11grab -r 1/1 -s 1680x1050 -i :0.0 -t 90 -qscale 1 -s 640x480 -vcodec mjpeg out.avi

No comments: