Search code examples
directshow

DirectShow: How to capture audio and video


I am looking for a way to capture my desktop. I came across something called direct Show but I cannot seem to get the syntax right on ffmpeg.

What can I do to capture the audio and video ?

I tried the syntax given in direct show site but not sure about it.


Solution

  • I just got mine to work and below i've given two examples of how you can do it and play it.

    First one is

    ffmpeg -f dshow -i video="screen-capture-recorder":audio="virtual-audio-capturer" -vcodec h264_nvenc -f mpegts udp://10.1.0.0:1234
    

    This will stream it in the same network in the udp link

    play it by typing ffplay udp://@10.1.0.0:1234. You can change the udp link to what you want. Try different variation so it work. or even type this into VLC, which will also make it work.

    2ND is

    ffmpeg -f dshow -i video="screen-capture-recorder":audio="virtual-audio-capturer" -vcodec h264_nvenc output.mp4

    You will get a mp4 file with the recording. Just press ctrl + c to stop the recording. Or if you know how long to record for add -t *seconds*. Replace seconds with actual number of seconds you want to record for. just add the -t before the output file name.