Knowledge base dedicated to Linux and applied mathematics.

Home > Linux > Software > Capture video of a linux desktop using ffmpeg

Capture video of a linux desktop using ffmpeg

Xdpyinfo is a utility for displaying information about an X server. It is used to examine the capabilities
of a server, the predefined values for various parameters used in communicating between clients and the
server, and the different types of screens and visuals that are available. (see man xdpyinfo).

We use it as follows to determine the screen resolution:

xdpyinfo | grep 'dimensions:'|awk '{print $2}'

FFmpeg can grab the X11 display

ffmpeg -f x11grab -i :0.0 /tmp/out.mpg

0.0 is display.screen number of your X11 server, same as the DISPLAY environment variable.

-r will be used to set the output file to 25 fps.

Now you know how to capture video of a linux desktop using ffmpeg:

ffmpeg -f x11grab -s `xdpyinfo | grep 'dimensions:'|awk '{print $2}'` -r 25 -i :0.0 -sameq /tmp/out.mpg

Any message or comments?

comments powered by Disqus