nvEncDXGIOutputDuplicationSample - Using YUV420 instead of NV12 causes error

I have the nvEncDXGIOutputDuplicationSample sample from NVIDIA’s GitHub. What I want to do seems like it should be relatively simple. I want to change the color conversion to convert to YUV420/I420 instead of NV12.

I changed this line from NV_ENC_BUFFER_FORMAT_NV12 to NV_ENC_BUFFER_FORMAT_IYUV, and then added

case NV_ENC_BUFFER_FORMAT_IYUV:
        return DXGI_FORMAT_420_OPAQUE;

to this switch block

Unfortunately, when I try and run the code now, I get Error 0x80070057 E_INVALIDARG in CreateVideoProcessorOutputView at this line

github.
com/NVIDIA/video-sdk-samples/blob/master/nvEncDXGIOutputDuplicationSample/Preproc.cpp#L141

Any ideas why? The modifications I made were so small so I can’t imagine why it would be causing a problem.

For D3D12 video, RTX 3070 only supports encoding NV12 format.
It’s probably just not supported on hardware level to use DXGI_FORMAT_420_OPAQUE directly, you must convert your textures to NV12 manually.

sorry, I want to change the color conversion to convert to YUV 444 instead of NV12.I also face the same problem at T4 card。can you help me

DXGI_FORMAT GetD3D11Format(NV_ENC_BUFFER_FORMAT eBufferFormat)
{
switch (eBufferFormat)
{
case NV_ENC_BUFFER_FORMAT_NV12:
return DXGI_FORMAT_NV12;
case NV_ENC_BUFFER_FORMAT_ARGB:
return DXGI_FORMAT_B8G8R8A8_UNORM;
case NV_ENC_BUFFER_FORMAT_YUV444:
return DXGI_FORMAT_AYUV;
default:
return DXGI_FORMAT_UNKNOWN;
}
}
HRESULT InitEnc()
{
if (!pEnc)
{
DWORD w = bNoVPBlt ? pDDAWrapper->getWidth() : encWidth;
DWORD h = bNoVPBlt ? pDDAWrapper->getHeight() : encHeight;
NV_ENC_BUFFER_FORMAT fmt;
fmt = bNoVPBlt ? NV_ENC_BUFFER_FORMAT_ARGB : NV_ENC_BUFFER_FORMAT_YUV444;

        pEnc = new NvEncoderD3D11(pD3DDev, w, h, fmt);
		.....
}

Unfortunately, when I try and run the code now, I get Error 0x80070057 E_INVALIDARG in CreateVideoProcessorOutputView at this line

github.
com/NVIDIA/video-sdk-samples/blob/master/nvEncDXGIOutputDuplicationSample/Preproc.cpp#L141

Any ideas why? The modifications I made were so small so I can’t imagine why it would be causing a problem.

T4 can support YUV444 h264,but I can’t test it ok

Hi fengliang191,

YUV444 is a completely different color format, it has no “compression” as compared NV12/YUV420, so I would be surprised if this would work out of the box.

Regarding your error message please try to debug the issue in your development environment first to see which argument is invalid and if it has anything to do with the color formats.

T4 has YUV444 encode capabilities, yes, that is correct.

Beyond that I am afraid I am unable to help here.