This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

How to configure encode parameters using OMX_SetConfig



I am using the following code to adjust the number of P frames between each I frame. I have noticed no change in the output of the encoder. It is always outputting NAL unit types in the following pattern: 27, 28, 25, 21, 21, ...

I expected to see some NAL units with type 25 but I never see any. How can I configure the encoder to periodically output I frames?

    OMX_VIDEO_CONFIG_AVCINTRAPERIOD config;
    OMX_INIT_PARAM( &config );
    config.nPortIndex = OMX_VIDENC_OUTPUT_PORT;
    eError = OMX_GetConfig( pHandle, OMX_IndexConfigVideoAVCIntraPeriod, (OMX_PTR)&config );
    if (eError != OMX_ErrorNone)
    {
        printf( "IL_ClientSetEncodeParams: OMX_GetConfig failed. %s\n", IL_ClientErrorToStr(eError) );
     return eError;
    }
    else
    {
     printf( "OMX_IndexConfigVideoAVCIntraPeriod nPFrames = %u, nIDRPeriod = %u\n", config.nPFrames, config.nIDRPeriod );
    }
    config.nPFrames = 29;
    eError = OMX_SetConfig( pHandle, OMX_IndexConfigVideoAVCIntraPeriod, (OMX_PTR)&config );
    if (eError != OMX_ErrorNone)
    {
        printf( "IL_ClientSetEncodeParams: OMX_SetConfig failed. %s\n", IL_ClientErrorToStr(eError) );
     return eError;
    }
    else
    {
     printf( "OMX_IndexConfigVideoAVCIntraPeriod nPFrames = %u, nIDRPeriod = %u\n", config.nPFrames, config.nIDRPeriod );
    }

 

  • Hi Steve,

    which version of SDK are you using ? Code changes looks fine.

    Could you please try OMX_SetParameter(pHandle, OMX_IndexParamVideoAvc, & config) as well before changing encoder state to IDLE.  It is create time parameters as well. Let me know if setparams takes effect.

    Regards

    Vimal

  • Hi Vimal,

    I am using versin 5_01_01_80. I added code as you suggested but still only a single I-Frame is output. Here is the code that I added ...

        OMX_VIDEO_PARAM_AVCTYPE config;
        OMX_INIT_PARAM( &config );
        config.nPortIndex = OMX_VIDENC_OUTPUT_PORT;
        eError = OMX_GetParameter( pHandle, OMX_IndexParamVideoAvc, &config );
        if (eError != OMX_ErrorNone)
        {
            printf( "IL_ClientSetEncodeParams: OMX_GetParameter(3) failed. %s\n", IL_ClientErrorToStr(eError) );
         return eError;
        }
        config.nPFrames = 10;
        eError = OMX_SetParameter( pHandle, OMX_IndexParamVideoAvc, &config );
        if (eError != OMX_ErrorNone)
        {
            printf( "IL_ClientSetEncodeParams: OMX_SetParameter(4) failed. %s\n", IL_ClientErrorToStr(eError) );
         return eError;
        }
        OMX_INIT_PARAM( &config );
        config.nPortIndex = OMX_VIDENC_OUTPUT_PORT;
        eError = OMX_GetParameter( pHandle, OMX_IndexParamVideoAvc, &config );
        if (eError != OMX_ErrorNone)
        {
            printf( "IL_ClientSetEncodeParams: OMX_GetParameter(3) failed. %s\n", IL_ClientErrorToStr(eError) );
         return eError;
        }
        else
        {
         printf( "nPFrames = %d\n", config.nPFrames );
        }

    I first get the parameter, then modify the nPFrames member (set to 10), then set the parameter, then get the parameter again to verify that the nPFrames member is set to the correct value.

    The code compiles and runs correctly and nPFrames is set to 10 but I only ever see a single I-Frame. This is a problem for me because I am trying to multi-cast the compressed frames via RTP and the client will need an occasional I-Frame to synchronize with the multi-cast.

    I have also noticed that no matter what the setting is for nPFrames (even if left at default), the encoder never outputs more than one I-Frame (at the beginning).

    Thanks, Steve

  • Steve,

    Did you mean IDR frame and not I frame ? IDR frame will be first frame after that I frame would come peridically. For forcing encoder to produce IDR frame you can use OMX_IndexConfigVideoIntraVOPRefresh config structure.

    Also EZSDK 5.2 is avilable on the web now, you could try that as well.

    Regards

    Vimal

  • Hi Vimal,

    Yes I meant IDR frame and your suggestion worked. I will also move to version 5.2 ASAP.

    Thanks,

    Steve