What raw image type is best for h.265 hardware encoding?

I have a USB3.0 camera. It can provide below formats
1280x720 MJPEG/ 1280x720 YUY2.

I am targeting to encode the stream into a h.265 movie file.

Which pipeline and/or transcoder should I use for hardware acceleration?

I am targeting to incorporate above framework into a C++ application.
Any C++ code snippet is most welcome … :)

We have tegra_multimedia_api samples. Please check 12_camera_v4l2_cuda. And this patch to hook encoder.

Thanks @DaneLLL

Sorry I didn’t mention in the post. I am targeting my application for Jetson Nano and want to use dedicated hardware video encoder.

Does ‘tegra_multimedia_api’ samples applicable for Nano dedicated hardware video encoder?