On newer jetpack versions from 5.X.X (tested primarily on 5.1.2), the video keeps looping on first buffers that were passed to the encoder. It seems like the encoder maps the given file descriptors for each input buffer (encoder was configured for 10 buffers on output plane) and expects the same FDs but with new data, which is not the use case in our software. I have reviewed multiple jetson multimedia API examples, including 10_camera_recording, but the logic in this example is different as the same FD is used repeatedly for both Argus and video encoder. The only workaround which I have found to be working is to map both the image FD and NvBuffer FD with NvBufSurfaceMap and copy the data with NvBufSurfaceCopy, which is highly inefficient and unnecessary. Is this a bug or should some extra steps be done in newer jetpack versions to get the encoder working properly?
I have reviewed the patch for using NvVideoEncoder in camera_v4l2_cuda example and implemented it into our application. The NvTransform function basically copies the input NvBuffer to the encoder NvBuffer, which is as inefficient as NvBufSurfaceCopy. On Jetson Xavier NX we are getting only ~18 FPS for 3840 x 2160 image resolution, which is nowhere near to the specification of 2x4K60 (H.265) encoding performance for this chip. I am aware that the limitation is the DMA buffer copy and not the encoding process itself, which is why I am trying to find a way to skip it altogether. The older NvBuffer API did not require any extra copying. Is there any way to achieve this?
I have tried the suggested steps you have mentioned and neither of those have helped the performance. It would seem like that the copy is necessary since jetpack 5, but the time it takes can be improved by using empty NvBufSurfTransformParams structure, which reduced the latency to only about 12 ms on Xavier NX, so now we are finally able to reach 30 FPS encoding at ~4K resolution. The problem itself has not been solved as the copy is in fact necessary, but the performance has been improved to the point that it is usable in our application.