NVIDIA maxine and encoding with CUDA instead of CPU

In the NVIDIA maxine example apps, opencv is using to encode, this is the line here:

const int fourcc_h264 = cv::VideoWriter::fourcc('H','2','6','4');

I have an ffmpeg built from source installed with CUDA support, I.E : hevc_nvenc and h264_nvenc codecs

Is it a matter of changing the fourcc code to encode with these codecs instead of CPU H264 ? If so, what’s the correct approach to achieve it ?

Thanks