Search code examples
ffmpeg

ffmpeg refuses to use audio device together with video capture (gdigrab)


I want to capture a recording of my screen along with sound. I have been able to peace together various SO answers and the documentation but I am struggling to put it all together.

With the following I can capture a video recording of my primary monitor:

ffmpeg -f gdigrab -framerate 30 -offset_x 0 -offset_y 0 -video_size 2560x1440 -show_region 1 -i desktop output.mp4 -y

I can also capture audio from a playing video with:

ffmpeg -f dshow -i audio="virtual-audio-capturer" output.m4a -y

I want to combine the two and capture a video and its sound that is playing.

cffmpeg -f gdigrab audio="virtual-audio-capturer" -framerate 30 -offset_x 0 -offset_y 0 -video_size 2560x1440 -show_region 1 -i desktop output.mkv -y

Gives me an error:

desktop: No such file or directory

Various other tries just return more errors. What am I doing wrong?

Also I am not particular about dshow or gdigrab, I am not sure what they are anyways. I just need it to work


Solution

  • Video and audio are separate inputs. Video is accessed through the gdigrab device and audio through dshow (Directshow). So,

    ffmpeg -f gdigrab -framerate 30 -offset_x 0 -offset_y 0 -video_size 2560x1440 -show_region 1 -i desktop -f dshow -i audio="virtual-audio-capturer" output.mp4 -y