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.

OMX H264 encoder, change framerate at runtime could not work.

Hello :

May I know is framerate could be set on the fly while H264 encoding on omap4430 ?

In our project, gstreamer and gst-openmax are used for camera and h264 encoder, and requirement is framerate and resolution are set on the fly, that's OMX Encoder and OMX camera maybe running for a while, when network condition slow down, framerate and resolution change on the fly;

I try to set framerate to omx_camera and omx_h264enc, but both failed;

test code is:

OMX_CONFIG_FRAMERATETYPE framerateType;
InitOMXParams(&framerateType);
framerateType.nPortIndex = 0;

status_t err = OMX_GetConfig(omx_handle, OMX_IndexConfigVideoFramerate,&framerateType);
if (err != OK) {
return BAD_VALUE;
}

framerateType.xEncodeFramerate = frameRate << 16;
err = OMX_SetConfig(omx_handle, OMX_IndexConfigVideoFramerate, &framerateType);
if (err != OK) {
return BAD_VALUE;
}

There is no error returned, but when I try to find the encoded file, the framerate is not changed.

Could you suggest? Thank you very much.

Br,

Ning.

  • Hello TI experts:

    I found following post : http://processors.wiki.ti.com/index.php/DM6446_Codecs

    That " 3) run time change in bit-rate, frame rate and resolution".

    In my test, config of OMX_IndexConfigVideoFramerate is not working, although there is not error return by ducati; while the encoded file is not change framerate actually.

    Do I need to change upstream too?

    And in omx_camera, return "OMX_ErrorUnsupportedIndex" while setting index OMX_IndexConfigVideoFramerate.

    Please help it, thank you very much.

    Br,

    Ning.

  • Code from Ducati for OMAP4 and DM6446 are different, OMX implementation is different.

    Can you share used release? is it 4AJ2.5P2? and a way to reproduce the issue? if possible.

    And if you are setting a regular fps or variable? and what code is in the surroundings if OMX_IndexConfigVideoFramerate.

  • Hello Manuel Contreras:

    Thank you for reply. Appreciated.

    Yes, I understand OMAP4 differs from DM6446, while " 3) run time change in bit-rate, frame rate and resolution", is this true for OMAP4 either? or only for DM6446, OMAP4 could not change framerate run time? Thanks.

    We are using release 4AI.1.7P1;

    Reproduce could be two ways, stagefright encoder and gstomx_h264enc:

    1. in StagefrightRecorder::StagefrightRecorder;

    a). in add function call of test_thread_func in StagefrightRecorder::StagefrightRecorder;

         pthread_create(&test_thread, NULL, test_thread_func, this);

    b).  static void *test_thread_func(void *vptr_args) {

          StagefrightRecorder *pRecorder = (StagefrightRecorder *)vptr_args;

          while (1) {

              sleep (10);

              pRecorder->setParameter (String8("video-config-encoding-framerate"), String8("10"));

              sleep (10);

              break;

            }

            return NULL;

          }

    2. in gstomx_h264enc.c, start test thread too, and function call:

          int changeFrameRate(GOmxCore *gomx, int frameRate) {

          OMX_CONFIG_FRAMERATETYPE framerateType;

          INIT_OMX_STRUCT(&framerateType, OMX_CONFIG_FRAMERATETYPE);

          framerateType.nPortIndex = 0;

          OMX_ERRORTYPE err = OMX_GetConfig(gomx->omx_handle, OMX_IndexConfigVideoFramerate,&framerateType);

          framerateType.xEncodeFramerate = frameRate << 16;

          err = OMX_SetConfig(gomx->omx_handle, OMX_IndexConfigVideoFramerate, &framerateType);

          GST_ERROR( "err=0x%x, xEncodeFramerate= %d",err, framerateType.xEncodeFramerate >> 16);

          return 0;

          }

    Default framerate is 30, while after seconds, I want to change framerate to 20, 15, 10 dynamically, that's to simulate our real application status;

    After above code setting, there is no error returned from ducati, and in ducati log file /d/remoteproc/omap-rproc.1/trace1, I also see following logs, you could see framerate change from 30 to 10 around; while after pull the encoded file, play from VLC, found it is still 30 fps but not 10;

    169:[    108.364] [MNU=2603] src/omx_video_rm_abstraction.c:[831]:RM::: nFrameSizeinMB 1900,xFramerate 1e, MHZ 61
    195:[    108.375] [MNU=2629] src/omx_video_rm_abstraction.c:[831]:RM::: nFrameSizeinMB 1900,xFramerate 1e, MHZ 61
    235:[    109.508] [MNU=2657] src/omx_video_rm_abstraction.c:[831]:RM::: nFrameSizeinMB 1646,xFramerate 1a, MHZ 53
    271:[    115.372] [MNU=2681] src/omx_video_rm_abstraction.c:[831]:RM::: nFrameSizeinMB 760,xFramerate c, MHZ 24
    282:[    120.146] [MNU=2692] src/omx_video_rm_abstraction.c:[831]:RM::: nFrameSizeinMB 506,xFramerate 8, MHZ 16

    Thanks.


    Br,

    Ning.

  • I was not able to find the fix for this issue, I tried to reproduce it using the code modification you shared but I was not able to get it compiled and I cannot find a way to reproduce it. Try to read-write-read the value to veirify it is being set and include the OMX_SetConfig for all the buffers until it is accepted, the other possibility is that it is needed to set to user value in other structure in order for Ducati to take this variable fps before changing the fps value.