Hello,
I am writing some research paper on h265 Encoding on Jetson XAVIER NX. We are comparing encoding from XAVIER NX hardware encoder with a reference implementation of h265 software encoding. We are working with constant QP values.
It seems XAVIER NX encoding has some problems with little QP values. At first it matches the reference, then it gets worse.
Maybe it is some configuration problem? I am using NvEncoder CPP class.
This is my function in which I create and configure the encoder.
#define SET_HW_PRESET
#define SET_PROFILE
#define NVBUFFER_FMT NvBufferColorFormat_NV12_10LE
#define INPUT_V4L2_FMT V4L2_PIX_FMT_P010M
#define ENCODER_PROFILE V4L2_MPEG_VIDEO_H265_PROFILE_MAIN10
bool Encoder::createVideoEncoder(float fps, int width, int height, int QP) {
int ret = 0;
m_VideoEncoder = NvVideoEncoder::createVideoEncoder("enc0");
if (!m_VideoEncoder)
ORIGINATE_ERROR("Could not create m_VideoEncoderoder");
ret = m_VideoEncoder->setCapturePlaneFormat(ENCODER_PIXFMT, width,
height, 2 * 1024 * 1024);
if (ret < 0)
ORIGINATE_ERROR("Could not set capture plane format");
ret = m_VideoEncoder->setOutputPlaneFormat(INPUT_V4L2_FMT, width,height);
if (ret < 0)
ORIGINATE_ERROR("Could not set output plane format");
ret = m_VideoEncoder->setFrameRate(int(fps*100), 100);
if (ret < 0)
ORIGINATE_ERROR("Could not set m_VideoEncoderoder framerate");
#ifdef SET_HW_PRESET
ret = m_VideoEncoder->setHWPresetType(V4L2_ENC_HW_PRESET_SLOW);
if (ret < 0)
ORIGINATE_ERROR("Could not set m_VideoEncoderoder HW Preset");
#endif
#ifdef SET_PROFILE
ret = m_VideoEncoder->setProfile(ENCODER_PROFILE);
if (ret < 0)
ORIGINATE_ERROR("Could not set m_VideoEncoderoder profile");
#endif
ret = m_VideoEncoder->setIFrameInterval(30);
if (ret < 0)
ORIGINATE_ERROR("Could not set I-frame interval");
std::cout << "QP: " << QP << std::endl;
ret = m_VideoEncoder->setConstantQp(QP);
if (ret < 0)
ORIGINATE_ERROR("Could not set constant qp");
ret = m_VideoEncoder->setNumReferenceFrames(1);
if (ret < 0)
ORIGINATE_ERROR("Could not set number of reference frames");
ret = m_VideoEncoder->setInsertVuiEnabled(true);
if (ret < 0)
ORIGINATE_ERROR("Could not set m_VideoEncoderoder InsertVui");
/* Query, Export and Map the output plane buffers so that we can read
raw data into the buffers */
//ret = m_VideoEncoder->output_plane.reqbufs(V4L2_MEMORY_DMABUF,5);
ret = m_VideoEncoder->output_plane.setupPlane(V4L2_MEMORY_DMABUF, 5, true, false);
if (ret < 0)
ORIGINATE_ERROR("Could not setup output plane");
/* Query, Export and Map the output plane buffers so that we can write
m_VideoEncoderoded data from the buffers */
ret = m_VideoEncoder->capture_plane.setupPlane(V4L2_MEMORY_MMAP, 6, true, false);
if (ret < 0)
ORIGINATE_ERROR("Could not setup capture plane");
printf("create video encoder return true\n");
return true;
}
You have any idea what could be configured wrong?
Best regards,
jb