NVIDIA Encoder APIs configuration

Dear all,

After encoding data and mux to mp4 file successfully, now I have two problems:

  1. I can not seek to anywhere in video file. May the reason is I frame?
  2. I want to split h264 stream to mux many mp4 files.

As I know, H264 frame have there major frame types as I, B, P. I’m not sure about IDR type and what difference to I type.

If I want to slit H264 stream to mux many mp4 files, I think I must split at the I or IDR frame.
Can you guys explain more about these VideoEncoder APIs:

  1. setIFrameInterval
  2. setIDRInterval
  3. forceIDR

How I can determine which frame is I or IDR type? I tried to use forceIDR API but it look like something wrong.

Thanks and Best Regards,
Vu Nguyen

Hi Vu,
Please refer to JM decoder Karsten Suehring
You can get information by enabling TRACE in JM/ldecod/inc/defines.h

# define TRACE           1     //!< 0:Trace off 1:Trace on 2:detailed CABAC context information

And check nal_unit_type, slice_type, idr_pic_id

For example, if we set

  1. setIFrameInterval = 5
  2. setIDRInterval = 15

You will see frames like
IDR PPPP I PPPP I PPPP IDR PPPP I PPPP I PPPP IDR …

forceIDR is a runtime parameter that it starts a new interval when it is set. For example, when it is set at 7th frame, it will be
IDR PPPP I P (starts a new interval) IDR PPPP I PPPP I PPPP IDR …

Hi DaneLLL,

Thanks, I will try and update to you.

Hi @DaneLLL,

I tried to set Encoder as below:

if (ctx->enc->setIFrameInterval(5) < 0)
        ERROR_RETURN("Failed to set up ENC frame interval");

    if (ctx->enc->setIDRInterval(15) < 0)
        ERROR_RETURN("Failed to set up ENC frame interval");

    if (ctx->enc->setFrameRate(30,1) < 0)
        ERROR_RETURN("Failed to set up ENC frame rate");

And I split H264 to many 15s mp4 files. There is only the first one can playback well, remain files display only black or gray screen when playing back.

Do you figure something?

Thanks

Hi,
For multiple files, you should need ‘–insert-spspps-idr’. Please give it a try.

Hi DaneLLL,
You’re correct. It work like a charm.
However I have to set IDR frame correct to first frame of each new file as below

STREAM_DURATION 30*30 //30 s
    if (ctx->enc->setIDRInterval(STREAM_DURATION) < 0)                                                
        ERROR_RETURN("Failed to set up ENC frame interval");                                          

    if (ctx->enc->setFrameRate(30,1) < 0)                                                             
        ERROR_RETURN("Failed to set up ENC frame rate");

    if (ctx->enc->setInsertSpsPpsAtIdrEnabled(true) < 0)                                              
        ERROR_RETURN("Failed to set SpsPps enable");

So if I got any mismatching all videos after this point couldn’t play back.

Thanks