<p>For capturing (NVIDIA GPU rendered) chrome window, GPU compositing must be disabled via --disable-gpu-compositing. Maybe you can also disable it in your application.</p>

CC BY-SA 4.0
2020-05-28T11:17:15.917Z
2020-05-28T11:17:15.917Z
user30015
<p><strong>Edit:</strong> I am using the terms "primary" &amp; "secondary" cards below loosely. I'm just assuming the Intel card is considered the first card.</p>

<p>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 <strong><em>gdigrab</em></strong> or <strong><em>dshow</em></strong> formats to specify on which card the window/app is being rendered?</p>

<p>Example of command with <em>gdigrab</em>:</p>

<pre><code>ffmpeg -format gdigrab -i title="&lt;window name&gt;" -c:v libx264 -preset ultrafast -qp 0 \
  -x264opts keyint="1" "&lt;outfile&gt;"
</code></pre>

<p>Example of command with <em>dshow</em> (window info read from registry):</p>

<pre><code>ffmpeg -format dshow -i video="video-capture-recorder" -c:v libx264 -preset ultrafast \
  -qp 0 -x264opts keyint="1" "&lt;outfile&gt;"
</code></pre>

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

<p>I did try using the <strong><em>hwaccel</em></strong> &amp; <strong><em>hwaccel_device</em></strong> 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?</p>

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

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

...

[AVHWDeviceContext @ 000001f78689ef40] cu-&gt;cuDeviceGet(&amp;cu_device, device_idx) failed -&gt; 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.
</code></pre>

<pre><code>ffmpeg -hwaccel_device 1 -hwaccel cuvid -f gdigrab -i title="&lt;window name&gt;" \
  -c:v libx264 -preset ultrafast -qp 0 -x264opts keyint="1" "&lt;outfile&gt;"
</code></pre>

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

<p>In case it helps, I am on an <a href="https://support.hp.com/us-en/document/c05381021" rel="nofollow noreferrer">HP Pavilion 24-b217c</a>.</p>

CC BY-SA 4.0
2019-02-12T11:12:30.173Z
Possibly related to https://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
CC BY-SA 4.0
2019-09-09T20:05:58.257Z
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
CC BY-SA 4.0
2019-09-09T20:07:28.107Z
You can of course change "desktop" to "<window name>" if there is a specific window you are trying to analyze.
Justin
CC BY-SA 4.0
2019-09-09T20:12:01.097Z
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
CC BY-SA 4.0
2019-09-09T20:15:43.983Z
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
<ffmpeg><video-capture><screen-casting>
FFmpeg Can't Capture Window Rendered with Secondary GPU
AntumDeluge
# FFmpeg Can't Capture Window Rendered with Secondary GPU

(Asked by: username_0 on 2019-02-12)

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="" -c:v libx264 -preset ultrafast -qp 0 \
  -x264opts keyint="1" ""

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" ""

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="" \
  -c:v libx264 -preset ultrafast -qp 0 -x264opts keyint="1" ""

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

...

[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="" \
  -c:v libx264 -preset ultrafast -qp 0 -x264opts keyint="1" ""

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.

**Tags:** ffmpeg, video-capture, screen-casting

> **Comments:**
> **username_1**: Possibly related to https://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.  
> **username_2**: 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.  
> **username_2**: You can of course change "desktop" to "<window name>" if there is a specific window you are trying to analyze.  
> **username_2**: 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.  
> **username_2**: 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.  

---

## 1 answers

### Answer by username_3 on 2020-05-28. Score: 0

For capturing (NVIDIA GPU rendered) chrome window, GPU compositing must be disabled via --disable-gpu-compositing. Maybe you can also disable it in your application.


---

