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
  • This command ffmpeg -f gdigrab -i desktop -c:v h264_nvenc -gpu list -f null - will list your GPUs for you and the index number. You may just need to switch around which GPU is being used for h/w encoding. Depending on how your devices get enumerated will dictate what GPU gets assigned to what index. Index of a GPU is usually pretty static, but not if you have a dockable GPU, e.g. Microsoft Surface Book 2, desktop with multiple cards, eGPU over Thunderbolt, etc. When you run that command you will get an error about the encoder, just ignore it. – Justin Sep 9 at 20:05
  • You can of course change "desktop" to "<window name>" if there is a specific window you are trying to analyze. – Justin Sep 9 at 20:07
  • There are known (well documented and understood) and known (poorly documented and poorly understood) issues with capturing hardware accelerated windows with any software solution, not just ffmpeg. That said, your error message indicates the 930MX is not capable of supporting the h/w decode option your requested. And looking through the NVidia encode/decode support matrix (which isn't always accurate), it does appear that your 930MX is not up to the job. Your CPU most likely has Intel QuickSync on it. – Justin Sep 9 at 20:12
  • When I say the NVidia encode/decode support matrix is inaccurate I mean that the information there is correct for those GPUs indicated to support the features, but often incomplete with missing GPU information or indicating that a GPU does not support that feature when in actuality it does because of the particular SKU of the GPU you happen to have. – Justin Sep 9 at 20:15

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.