9

How to stream Desktop using FFMPEG in Windows?

I have tried ffmpeg -list_devices true -f dshow -i dummy

and after that this to stream

ffmpeg -f dshow  -i video="Chicony USB 2.0 Camera"  -r 30 -vcodec mpeg4 -q 12 -f mpegts        udp://192.168.2.7:6666?pkt_size=188?buffer_size=65535

Using this i got to stream the Camera.

What command do I have to type to stream the Desktop in Windows?

3 Answers 3

7

Capture desktop using built-in GDI screengrabber:

ffmpeg -f gdigrab -framerate 30 -i desktop output.mkv

Stream it:

ffmpeg -f gdigrab -framerate 30 -i desktop -vcodec mpeg4 -q 12 -f mpegts udp://192.168.2.7:6666

Play the stream:

ffplay -f mpegts udp://192.168.2.1:6666

Save the stream:

ffmpeg -f mpegts -i udp://192.168.2.1:6666 output.mkv

Here you can find an example with audio in the same stream.

And don't worry if the video stream doesn't start immediately and ffmpeg ouputs errors like "non-existing PPS 0 referenced" - you just didn't receive a keyframe yet, wait a dozen of seconds and it should come up.

3

Or, you can use UScreenCapture. It's using the DShow API of DirectX, and available for both x86 and x64 architectures. After you installed it, you'll find a new input source "UScreenCapture", witch is your live desktop screen respectively.

If you're sending it to a Wowza server, here's the command what you need:

ffmpeg -f dshow -i video="UScreenCapture" -s **width** x **height** -r **framerate** -vcodec libx264 -pix_fmt yuv420p -b:v **bitrate** -an -vbsf h264_mp4toannexb -f mpegts udp://**your.destination.url:PORTNUMBER**?pkt_size=1316

Note that I explicitly changed the pixel format(pix_fmt), because ffmpeg used yuv444p instead of yuv420p. I had to do this to make it work.

It works pretty well for me.

Regards, G.

1
  1. Download FFmpeg. Either 64-bit or 32-bit should work.

  2. Install Screen Capturer Recorder. The installer should automatically install Microsoft Visual C++ Redistributable as well, if needed.

  3. Use

    ffmpeg -f dshow -i video=screen-capture-recorder -r 24000/1001 -q 1 out.avi
    

FFmpeg screencast Windows

3
  • thanks, but is there a way to do it without 3rd party applications??
    – Searush
    Nov 10, 2012 at 10:47
  • On Win systems the answer is unfortunately no. Jan 28, 2015 at 9:31
  • If you have Linux system (with running X server), you can use the built in x11grab device like this: ffmpeg -f x11grab -framerate 25 -video_size 1280x720 -i :0.0 [...] Check the official documentation [here].(ffmpeg.org/ffmpeg-devices.html#toc-x11grab) Jan 28, 2015 at 9:37

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .