FFMPEG on Jetson Xavier

I am trying to use FFMPEG on Jetson Xavier to convert an OpenCV image to an FFMPEG AVFrame and then to a packet for streaming, While creating the HW context for encoding, I get a "Could not allocate memory " error using the AV_HWDEVICE_TYPE_VDPAU device. I feel this device is wrong but I am not sure what is the correct device then. Is there something to use NVENC as the device?

         AVBufferRef* hw_device_ctx;
         return_value = av_hwdevice_ctx_create(&hw_device_ctx, AV_HWDEVICE_TYPE_VDPAU,
                                               nullptr, nullptr, 0)