Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Capture Windows screen with ffmpeg

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?

like image 969
kamae Avatar asked Jul 20 '11 18:07

kamae


People also ask

How do I record desktop with ffmpeg?

-f x11grab is what actually tells FFmpeg to record your screen. You shouldn't change that. -i :0.0+0,0 is where you specify the x and y offset of the top left corner of the area that you want to record. For example, use :0.0+100,200 to have an x offset of 100 and an y offset of 200.


2 Answers

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.

like image 58
frustrated Avatar answered Sep 22 '22 13:09

frustrated


This will help for capturing the working screen on windows :

ffmpeg -y -rtbufsize 100M -f gdigrab -t 00:00:30 -framerate 30 -probesize 10M -draw_mouse 1 -i desktop -c:v libx264 -r 30 -preset ultrafast -tune zerolatency -crf 25 -pix_fmt yuv420p c:/video_comapre2.mp4

like image 40
M. D. P Avatar answered Sep 20 '22 13:09

M. D. P