0

Edit: I am using the terms "primary" & "secondary" cards below loosely. I'm just assuming the Intel card is considered the first card.

I recently discovered how to use my secondary graphics card (nVidia GeForce 930MX) to render a game on my Windows 10 system. However, when I do so, FFmpeg no longer captures what is displayed in that window. It captures whatever is displayed from the primary card (Intel(R) HD Graphics 630) at the coordinates of said window. Is there an argument that can be passed to FFmpeg's gdigrab or dshow formats to specify on which card the window/app is being rendered?

Example of command with gdigrab:

ffmpeg -format gdigrab -i title="<window name>" -c:v libx264 -preset ultrafast -qp 0 \
  -x264opts keyint="1" "<outfile>"

Example of command with dshow (window info read from registry):

ffmpeg -format dshow -i video="video-capture-recorder" -c:v libx264 -preset ultrafast \
  -qp 0 -x264opts keyint="1" "<outfile>"

I have been searching around the internet for quite a while, but haven't found much information on it.

I did try using the hwaccel & hwaccel_device arguments, but still Intel card is captured. I'm thinking these are actually to allow FFmpeg to take advantage of the hardware resources for its own performance?

ffmpeg -hwaccel_device 0 -hwaccel nvdec -f gdigrab -i title="<window name>" \
  -c:v libx264 -preset ultrafast -qp 0 -x264opts keyint="1" "<outfile>"
ffmpeg -hwaccel_device 1 -hwaccel nvdec -f gdigrab -i title="<window name>" \
  -c:v libx264 -preset ultrafast -qp 0 -x264opts keyint="1" "<outfile>"

...

[AVHWDeviceContext @ 000001f78689ef40] cu->cuDeviceGet(&cu_device, device_idx) failed -> CUDA_ERROR_INVALID_DEVICE: invalid device ordinal
Device creation failed: -1313558101.
[bmp @ 000001f7883ada40] No device available for decoder: device type cuda needed for codec bmp.
ffmpeg -hwaccel_device 1 -hwaccel cuvid -f gdigrab -i title="<window name>" \
  -c:v libx264 -preset ultrafast -qp 0 -x264opts keyint="1" "<outfile>"

Edit: Perhaps because the command using -hwaccel_device 0 -hwaccel nvdec doesn't exit with an error, this means that the nVidia GPU is considered card 0 & Intel is card 1?

In case it helps, I am on an HP Pavilion 24-b217c.

  • Possibly related to trac.ffmpeg.org/ticket/7718 although in your case, it appears the final buffer is composited at a latter stage, so not accessible to gdigrab. nvdec/hwaccel is irrelevant here, as they are meant for decoding compressed input on the GPU. You are working with raw frames as input. – Gyan Feb 12 at 11:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.