Having trouble using Reconfigure

OS: Windows 2019 Server, 64-bit
SDK: 9.0.20
Driver version: 419.69

Called like this:

encoder->reconfigure(8 * 1000000, 4 * 1000000);
bool Encoder::reconfigure(uint32_t max_bitrate, uint32_t avg_bitrate) {
        NV_ENC_INITIALIZE_PARAMS init_params;
        NV_ENC_CONFIG encodeConfig;
        memset(&encodeConfig, 0, sizeof(encodeConfig));
        memset(&init_params, 0, sizeof(init_params));
        init_params.encodeConfig = &encodeConfig;
        this->encoder->GetInitializeParams(&init_params);

        if (!init_params.encodeConfig) {
            printf("Didn't get InitializeParams\n");
            return false;
        }

        NV_ENC_RECONFIGURE_PARAMS params;
        memset(&params, 0, sizeof(params));
        params.version = NV_ENC_RECONFIGURE_PARAMS_VER;
        params.forceIDR = 1;
        params.resetEncoder = 1;

        encodeConfig = *(init_params.encodeConfig);

        if (max_bitrate) encodeConfig.rcParams.maxBitRate = max_bitrate;
        if (avg_bitrate) encodeConfig.rcParams.averageBitRate = avg_bitrate;

        params.reInitEncodeParams.encodeConfig = &encodeConfig;

        printf("Set reconfigure params...\n");

        return this->encoder->Reconfigure(&params); // Program terminates
    }

For some reason my program terminates as soon as it hits line 29. Likely due to an Exception thrown that for some reason I cannot see the message for.

I’d love help either understanding (a) why this doesn’t work in the first place or (b) how to get the error log easily to see what happened.

1 Like

I’m experiencing the same issue. I managed to get a bit more information about the error:
The call to the reconfigure encoder api is returning a NV_ENC_ERR_INVALID_VERSION response.

The library I’m using uses the following macro to define the version:
#define NVENCAPI_MAJOR_VERSION 9
#define NVENCAPI_MINOR_VERSION 0
#define NVENCAPI_VERSION (NVENCAPI_MAJOR_VERSION | (NVENCAPI_MINOR_VERSION << 24))
#define NVENCAPI_STRUCT_VERSION(ver) ((uint32_t)NVENCAPI_VERSION | ((ver)<<16) | (0x7 << 28))
#define NV_ENC_RECONFIGURE_PARAMS_VER (NVENCAPI_STRUCT_VERSION(1) | ( 1<<31 ))

Is there something wrong with the calculated version?? As far as I can tell it’s the same as in the standard example: video-sdk-samples/nvEncodeAPI.h at aa3544dcea2fe63122e4feb83bf805ea40e58dbe · NVIDIA/video-sdk-samples · GitHub