NvEncReconfigureEncoder fails on latest 430 drivers

NvEncReconfigureEncoder returns error 218 on latest 430 drivers
I have no issue with 418 driver.

Please help.

Hi LiranBachar,
Can you provide your setup details and exact steps to reproduce this issue?

Hi mandar_godse

in order to reproduce, please add the following code after encoder initialization:

NV_ENC_RECONFIGURE_PARAMS stReconfigParams = { 0 };
        memset(&stReconfigParams, 0, sizeof(stReconfigParams));
        memcpy(&stReconfigParams.reInitEncodeParams, &initializeParams, sizeof(initializeParams));
        stReconfigParams.version = NV_ENC_RECONFIGURE_PARAMS_VER;
        stReconfigParams.resetEncoder = 1;
        stReconfigParams.forceIDR = 1;
        stReconfigParams.reInitEncodeParams.encodeWidth = 120;  // differs from initializeParams
        stReconfigParams.reInitEncodeParams.encodeHeight = 100; // differs from initializeParams
        enc.nvEncReconfigureEncoder(m_hEncoder, &stReconfigParams);

nvEncReconfigureEncoder invocation works fine with the driver 419.67 and fails with 430.39 and 430.64 with the error code 8 (NV_ENC_ERR_INVALID_PARAM)
maxEncodeWidth & maxEncodeHeight are set at initialization

in order to reproduce please clone https://github.com/NVIDIA/video-sdk-samples.git
and apply the following patch

Samples/AppEncode/AppEncQual/AppEncQual.cpp | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/Samples/AppEncode/AppEncQual/AppEncQual.cpp b/Samples/AppEncode/AppEncQual/AppEncQual.cpp
index d562d2f..4cebf33 100644
--- a/Samples/AppEncode/AppEncQual/AppEncQual.cpp
+++ b/Samples/AppEncode/AppEncQual/AppEncQual.cpp
@@ -208,6 +208,16 @@ void EncQual(char *szInFilePath, char *szOutFilePath, int nWidth, int nHeight, N
         shift = 0;
     }
 
+    NV_ENC_RECONFIGURE_PARAMS stReconfigParams = { 0 };
+    memset(&stReconfigParams, 0, sizeof(stReconfigParams));
+    memcpy(&stReconfigParams.reInitEncodeParams, &initializeParams, sizeof(initializeParams));
+    stReconfigParams.version = NV_ENC_RECONFIGURE_PARAMS_VER;
+    stReconfigParams.resetEncoder = 1;
+    stReconfigParams.forceIDR = 1;
+    stReconfigParams.reInitEncodeParams.encodeWidth = 120;
+    stReconfigParams.reInitEncodeParams.encodeHeight = 100;
+    enc.Reconfigure(&stReconfigParams);
+
     do 
     {
         nRead = fpYuv.read(reinterpret_cast<char*>(vEncFrame[iEnc % nFrame].get()), nSize).gcount();

open in VisualStudio and set AppEncQual as a startup project
select Debug x64
set command line params: -i “path_to_your_file” -s WxH -o out.avi

The encode resolution you are specifying during reconfigure is less than the minimum resolution hardware can support. If you try reconfigure with higher resolution (e.g. QCIF or higher), that should work. The check for minimum resolution was added in r421 series driver; hence you do not see this issue with an older driver. Future SDK will enable client application to query the minimum supported resolution.

Hi Mandar Godse

Thanks for the reply

In our software, we encode a lot of low-resolution videos and this functionality perfectly worked on most Nvidia GPUs (gtx, rtx, quadro and tesla). It means this low-resolution limitation did not exist in old drivers.

With new drivers I tried different resolutions - looks like the minimal resolution on my RTX 2070 and R430.64 driver is 160x64.

Then I tried to decode a low-resolution clip (118x104) with AppDec application from https://github.com/NVIDIA/video-sdk-samples.git - it works. But I can not encode the video because of this new limitation.

It means the decoder and encoder are not symmetric and we can not transcode a low-resolution video.

Thus the latest drivers (R430 and higher) brake both backward compatibility and transcoding capability of low-resolution videos.

Could you provide a workaround solution for us how to encode low-resolution video with new drivers?

Thanks

Hi Alex_V,
Let me clarify, though minimum resolution check is added in r421 series driver,
I think your issue is specific to Turing GPU.

For h264 decode, minimum resolution required is 48x16 for all GPUs.
For h264 encode,
minimum resolution required is 145x49 for Turing GPU
minimum resolution required is 33x17 for Volta and below GPUs.

Since minimum resolution is a hardware requirement, there is no workaround available. For the resolutions below the minimum resolution, do you have an option of using the CPU, if yes there are CPU options also available.

Hi Mandar Godse

Thanks for the reply

You said that there is a hardware limit for minimum resolution, However:

on my RTX 2070 (Turing) driver R419.67 (old driver) - Encoding 118x104 video works

The process succeeded (output files are playable).
I verified the use of h/w encoder (through monitoring the GPU encoder’s utilization).

Could you explain how low-resolution encoding works with old drivers?
We have been using this ability for years, it recently broke with the new drivers.
Please elaborate on the limitation.

Thanks

Hi Alex_V,
In your specific test on RTX 2070 and R419 driver, 118x104 encoding may have worked.
But, in general it will result in the failure and hence later driver added checks to return error code.

The pre-Turing minimum resolution is smaller than 118x104, and is expected to continue to work for you.
Refer to my minimum resolution limitations from comment #6.

Hi Mandar Godse

Thanks for the reply

Could you provide exact minimum resolution for Turing GPU that works?
145x49 that you mentioned fails

Thanks

Hi Alex_V,
Sorry, I only looked at the top of the tree code earlier.

For r421/r430:
Turing and beyond
o H264: 160x64
o HEVC: 129x33

For upcoming driver:
Turing and beyond
o H264: 145x49
o HEVC: 129x33

H264 minimum resolution in 421/430 driver is incorrect and is later fixed in the upcoming r435 driver.
Sorry for the inconvenience.