Orin NX jetpack 5 Encoder performance issue

Hi, I am using Orin NX with Jetpack 5.1.4 for h265 video encoding. I found that the encoder performance was not near the spec.
Starting from Jetpack5, I found NvTransform is required for encoder fd while the previous version doesn’t require NvTransform before encoding.
Could this be the issue and how to achieve 30 FPS for 4K encoding?
Share some sample code in case:

void video_codec::VideoCodec::startVideoEncoding(int input, std::string sourceId) {
    int index = std::stoi(sourceId);
    Context *context = contexts.at(index);
    NvVideoEncoder *videoEncoder = context->videoEncoder;
    int *bufferIndex = &context->bufferIndex;
    v4l2_buffer *v4l2_buf = &context->buffer;
    int newfd = -1;

    // The queue is not full, no need to dqBuffer
    if (*bufferIndex < 5 &&
        videoEncoder->output_plane.getNumQueuedBuffers() < videoEncoder->output_plane.getNumBuffers()) {
        v4l2_buf->index = *bufferIndex;
        NvBufSurf::NvCommonAllocateParams cParams;
        if (std::find(cvCameraIds.begin(), cvCameraIds.end(), sourceId) != cvCameraIds.end()) {
            cParams.width = 3840;
            cParams.height = 2160;
        } else {
            cParams.width = 1920;
            cParams.height = 1200;
        }
        cParams.layout = NVBUF_LAYOUT_PITCH;
        cParams.colorFormat = get_nvbuff_color_fmt(V4L2_PIX_FMT_YUV420M);
        cParams.memtag = NvBufSurfaceTag_VIDEO_ENC;
        cParams.memType = NVBUF_MEM_SURFACE_ARRAY;
        if (-1 == NvBufSurf::NvAllocate(&cParams, 1, &newfd)) {
            spdlog::error("Failed to create NvBuffer");
        }
        *bufferIndex = *bufferIndex + 1;
    } else {
        // Output plane full or max outstanding number reached
        NvBuffer *shareBuffer;
        videoEncoder->output_plane.dqBuffer(*v4l2_buf, NULL,
                                            &shareBuffer, 10/*retry*/);
        newfd = v4l2_buf->m.planes[0].m.fd;
    }
    NvBufSurf::NvCommonTransformParams transform_params = {0};
    NvBufSurf::NvTransform(&transform_params, input, newfd);
    v4l2_buf->m.planes[0].m.fd = newfd;
    v4l2_buf->m.planes[0].bytesused = 1;
    videoEncoder->output_plane.qBuffer(*v4l2_buf, NULL);

}

Hi,
Please apply the items and see if there is improvement:

  1. Enable maximum performance mode to encoder
  2. Send NV12 blocklinear NVBufSurface to encoder
  3. Execute the script to run VIC at maximum clock

VPI - Vision Programming Interface: Performance Benchmark

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.