Capture Windows screen with ffmpeg

kamae picture kamae · Jul 20, 2011 · Viewed 83.7k times · Source

The ffmpeg is cross-platform and very powerful software to handle video/audio or to stream it. On Linux ffmpeg can capture X11 screen with a command below:

ffmpeg -f x11grab -r 25 -s cif -i :0.0 out.mpeg

But is it possible to grab Windows Desktop with ffmpeg?

Answer

frustrated picture frustrated · Jun 26, 2015

Use the built-in GDI screengrabber (no install needed) like this :

ffmpeg -f gdigrab -framerate 10 -i desktop [output]

This will capture ALL your displays as one big contiguous display.

If you want to limit to a region, and show the area being grabbed:

ffmpeg -f gdigrab -framerate ntsc -offset_x 10 -offset_y 20 -video_size 640x480 \
-show_region 1 -i desktop [output]

To grab the contents of the window named "Calculator":

ffmpeg -f gdigrab -framerate 25 -i title=Calculator [output]

I found that framerate 10 suits screen capture well (you can change it).

I have encoded to both files and streaming outputs and it works quite well.