On Jetpack 4.6.1, please use NvBuffer APIs. And this method should work:
Copy OpenCV GpuMat data to an NvBuffer - #9 by sanatmharolkar
This was helpful with getting the code to work for CPU encoding, thank you.
You may see: OpenCV CUDA processing from gstreamer pipeline [JP4, JP5]
This was helpful in figuring out the process for GPU encoding, thank you. I hadn’t been using your GetPitch function and was getting a video with the right colors but bad alignment until I switched.
Although it works well now, there doesn’t seem to be much of a speedup compared to the CPU method and cudaMemcpyDefault. Approximately 0.2 seconds per 500 hundred frames or so (in total 14.9 seconds for GPU encoding and 15.1 seconds for CPU encoding including setup). For 40 frames, it is only about 0.1 seconds faster.
I notice the time between successive frame writes to the output file did not change in terms of time taken. Are there other measures I need to take for the capture plane as well to utilize GPU encoding?