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.

Key Frame duration in omx_mpeg4enc in dm 816x

Hi,


We are using below pipeline for recording

omx_videosrc->clockoverlay->omx_mpeg4enc->avimux->filesink

In the output file , first frame is a key frame. Then key frames are not seen. This creates a problem in file seeking during playback.

For another case, we are using omx_h264enc. In omx_h264enc, we were able to set I-frame periodicity using "i-period" and "force-idr-period" properties of encoder.

Are there any similar properties that can be set for omx_mpeg4enc to force I-frame periodicity?

Or is there any other mechanism to force I-frame frequency?

Thanks in advance

Fazil

  • Hi Fazil,

    You can set I frame periodicity in MPEG4 encoding also.

    You can try below settings from your iLClient

    OMX_VIDEO_CONFIG_DYNAMICPARAMS tDynParams;
    OMX_INIT_PARAM (&tDynParams);

    tDynParams.nPortIndex = OMX_VIDENC_OUTPUT_PORT;

    eError = OMX_GetParameter (pHandle, OMX_TI_IndexParamVideoDynamicParams,
    &tDynParams);

    tDynParams.videoDynamicParams.mpeg4EncDynamicParams.videnc2DynamicParams.intraFrameInterval = N; //N > 1

    eError = OMX_SetParameter (pHandle, OMX_TI_IndexParamVideoDynamicParams,
    &tDynParams);

    Encoded bitstream will have I frame for every Nth frame .

    Ram

  • Hello,

    You could use:

    gst-inspect "omx_mpeg4enc" to check what are the supported properties for gstreamer mpeg4encoder element.

    You could find the omx_mpeg4enc source under gstreamer/omx dir in component-sources also.

    BR
    Margarita

  • Hi Ram,

    We tried this, by hardcoding the value 30 for intraFrameInterval in DynamicParams. But still it shows the same behaviour.

    Can I do it this way by hardcoding the value, or is there any other way to do this ?

    Regards
    Fazil
  • Hi Margarita,

    I checked using gst-inspect. But there are no properties related to i-frame periodicity exposed.

    I got another reply from person named Ram, saying to set intraFrameInterval of mpeg4encoder dynamic params. But that also did not work.

    Is there any other method that I can try?


    Regards
    Fazil
  • Hi Fazil,

    Do you have acccess to ezsdk overlay? If you have, you can modify to set intraFrameinterval and rebuild video firmmare.

    In OMX_TI_MPEG4VE_SetDefaultDynamicParams() of  src/ti/omx/comp/venc/src/omx_mpeg4ve.c, intraFrameinterval is set to 0. Modify this for your requirement and rebuild xem3.

  • Hello Mohammed,


    Ram suggested you to check with the OMX encode demo not gstreamer.
    Did you check with the OMX demo?

    You could check the gstreamer omx_h264enc.h/.c and omx_mpeg4enc.h/.c

    In omx_h264enc.h we have as properties:

    struct GstOmxH264Enc
    {
    GstOmxBaseVideoEnc omx_base;
    gboolean bytestream;
    gint idr_period;
    gint force_idr;
    OMX_VIDEO_AVCPROFILETYPE profile;
    OMX_VIDEO_AVCLEVELTYPE level;
    gint i_period;
    OMX_VIDEO_ENCODING_MODE_PRESETTYPE encodingPreset;
    OMX_VIDEO_RATECONTROL_PRESETTYPE ratecontrolPreset;
    gint cont;
    };

    In omx_mpeg4enc we have :

    struct GstOmxMpeg4Enc
    {
    GstOmxBaseVideoEnc omx_base;
    };

    Let us know the results.

    BR
    Margarita
  • Hi Ram,

    I tried setting intraFrameinterval to value 30, in OMX_TI_MPEG4VE_SetDefaultDynamicParams() of src/ti/omx/comp/venc/src/omx_mpeg4ve.c file. But I-frames are observed rarely

    Regards
    Fazil
  • Hello,

    I checked with OMX encode demo.
    I changed the omx_mpeg4ve.c file and rebuilt the overlay package. I cp the new dm816x_hdvicp.xem3 and loaded it.
    The video is running fine (on every 10 frames there is I frame in my case).

    Note: In omx_mpeg4ve.c file I change the intraFrameInterval at two places.

    Please verify your settings and steps.

    My mpeg4 encoder version is ivahd_mpeg4enc_01_00_00_05_production.

    Did you change it in both lines in omx_mpeg4ve.c file(around 726 and 878 line)?

    BR
    Margarita

  • Hi Margarita,

    Thank you for the valuable reply.

    In omx_mpeg4ve.c file :
    I changed in OMX_TI_MPEG4VE_SetDefaultDynamicParams() line number 726 only.
    Line no. 878 comes in OMX_TI_MPEG4VE_H263SetDefaultDynamicParams() function. Is this change also required?

    How to build overlay package alone? Is it by the command "sudo make -f Overlay.Makefile" ?

    I could see dm816x_hdvicp.xem3 in two paths after SDK build as below

    ti-ezsdk_dm816x-evm_5_05_02_00/createFS/usr/share/ti/ti-media-controller-utils/dm816x_hdvicp.xem3
    ti-ezsdk_dm816x-evm_5_05_02_00/board-support/prebuilt-images/dm816x-firmware_05_02_00_48/dm816x_hdvicp.xem3

    Which path actually we need to copy "dm816x_hdvicp.xem3" from and where to copy to?
    Currently we are building the SDK and writing the image to SD card.

    Could you please explain how to load "dm816x_hdvicp.xem3" alone after making the changes?

    Meanwhile, I will change line no:878 also in omx_mpeg4ve.c file and check it again.

    Regards
    Fazil
  • Hello,

    I changed it in both lines.

    Regarding the firmware:

    - you could use this command : make -f Overlay.Makefile all
    This will rebuild the HDVICP, HDVPSS firmwares.
    -the new firmwares you could find :/component-sources/omx-ti81xx-src_05_02_00_48/bin/dm816xbm/bin/ti816x-evm
    - dm816xbm_m3video_whole_program_debug.xem3 this is the HDVICP firmware.
    -rename it to dm816x_hdvicp.xem3
    -cp to sd card under /usr/share/ti/ti-media-controller-utils/
    -boot the board.

    This way you will replace the old HDVICP firmware.

    BR
    Margarita

  • Hi Margarita,

    I could
    -build the video firmware alone
    -Renamed to dm816x_hdvicp.xem3 and copied to /usr/share/ti/ti-media-controller-utils/
    - Reboot

    But when I run my application, I am getting error as below

    OMX_EventError: 0x80001005
    unrecoverable error: One or more parameters were not valid (0x80001005)


    Please see the firmware loading logs below, I could see a warning that "the firmware is newer, driver may not work properly" at the end of the log.

    Loading HDVICP2 Firmware
    DM816X prcm_config_app version: 2.0.0.1
    Doing PRCM settings...
    PRCM for IVHD0 is in Progress, Please wait.....
    BW Phy Addr : 0x48180600 Data : 0x00000002
    AW Phy Addr : 0x48180600 Data : 0x00000002
    Phy Addr : 0x48180c04 Data : 0x00000037
    BW Phy Addr : 0x48180620 Data : 0x00070000
    AW Phy Addr : 0x48180620 Data : 0x00070002
    BW Phy Addr : 0x48180624 Data : 0x00030000
    AW Phy Addr : 0x48180624 Data : 0x00010002
    Phy Addr : 0x48180600 Data : 0x00000102
    BW Phy Addr : 0x48180c10 Data : 0x00000007
    AW Phy Addr : 0x48180c10 Data : 0x00000003
    Phy Addr : 0x48180c14 Data : 0x00000004
    BW Phy Addr : 0x58088000 Data : 0x3f3245ce
    AW Phy Addr : 0x58088000 Data : 0xeafffffe
    BW Phy Addr : 0x58098000 Data : 0xc32ac65e
    AW Phy Addr : 0x58098000 Data : 0xeafffffe
    BW Phy Addr : 0x48180c10 Data : 0x00000003
    AW Phy Addr : 0x48180c10 Data : 0x00000000
    Phy Addr : 0x48180c14 Data : 0x00000007
    PRCM for IVHD0 is Done Successfully
    PRCM for IVHD1 is in Progress, Please wait.....
    BW Phy Addr : 0x48180700 Data : 0x00000002
    AW Phy Addr : 0x48180700 Data : 0x00000002
    Phy Addr : 0x48180d04 Data : 0x00000037
    BW Phy Addr : 0x48180720 Data : 0x00070000
    AW Phy Addr : 0x48180720 Data : 0x00050002
    BW Phy Addr : 0x48180724 Data : 0x00030000
    AW Phy Addr : 0x48180724 Data : 0x00010002
    Phy Addr : 0x48180700 Data : 0x00000102
    BW Phy Addr : 0x48180d10 Data : 0x00000007
    AW Phy Addr : 0x48180d10 Data : 0x00000003
    Phy Addr : 0x48180d14 Data : 0x00000004
    BW Phy Addr : 0x5a088000 Data : 0x2f760f90
    AW Phy Addr : 0x5a088000 Data : 0xeafffffe
    BW Phy Addr : 0x5a098000 Data : 0xf58bbb9f
    AW Phy Addr : 0x5a098000 Data : 0xeafffffe
    BW Phy Addr : 0x48180d10 Data : 0x00000003
    AW Phy Addr : 0x48180d10 Data : 0x00000000
    Phy Addr : 0x48180d14 Data : 0x00000007
    PRCM for IVHD1 is Done Successfully
    PRCM for IVHD2 is in Progress, Please wait.....
    BW Phy Addr : 0x48180800 Data : 0x00000002
    AW Phy Addr : 0x48180800 Data : 0x00000002
    Phy Addr : 0x48180e04 Data : 0x00000037
    BW Phy Addr : 0x48180820 Data : 0x00070000
    AW Phy Addr : 0x48180820 Data : 0x00050002
    BW Phy Addr : 0x48180824 Data : 0x00030000
    AW Phy Addr : 0x48180824 Data : 0x00010002
    Phy Addr : 0x48180800 Data : 0x00000102
    BW Phy Addr : 0x48180e10 Data : 0x00000007
    AW Phy Addr : 0x48180e10 Data : 0x00000003
    Phy Addr : 0x48180e14 Data : 0x00000004
    BW Phy Addr : 0x53088000 Data : 0xca822e01
    AW Phy Addr : 0x53088000 Data : 0xeafffffe
    BW Phy Addr : 0x53098000 Data : 0xef2e1d25
    AW Phy Addr : 0x53098000 Data : 0xeafffffe
    BW Phy Addr : 0x48180e10 Data : 0x00000003
    AW Phy Addr : 0x48180e10 Data : 0x00000000
    Phy Addr : 0x48180e14 Data : 0x00000007
    PRCM for IVHD2 is Done Successfully
    PRCM Initialization completed
    SysLink version : 2.20.02.20
    SysLink module created on Date:May 3 2016 Time:12:58:28
    FIRMWARE: I2cInit will be done by M3
    FIRMWARE: Memory map bin file not passed
    Usage : firmware_loader <Processor Id> <Location of Firmware> <start|stop> [-mmap <memory_map_file>] [-i2c <0|1>]
    ===Mandatory arguments===
    <Processor Id> 0: DSP, 1: Video-M3, 2: Vpss-M3
    <Location of Firmware> firmware binary file
    <start|stop> to start/stop the firmware
    ===Optional arguments===
    -mmap input memory map bin file name
    -i2c 0: i2c init not done by M3, 1(default): i2c init done by M3
    FIRMWARE: isI2cInitRequiredOnM3: 1
    FIRMWARE: Default memory configuration is used
    Firmware Loader debugging not configured
    Default FL_DEBUG: warning
    Allowed FL_DEBUG levels: error, warning, info, debug, log
    MemCfg: DCMM (Dynamically Configurable Memory Map) Version : 2.1.2.1
    FIRMWARE: 1 start Successful
    Loading HDVPSS Firmware
    FIRMWARE: I2cInit will be done by M3
    FIRMWARE: Memory map bin file not passed
    Usage : firmware_loader <Processor Id> <Location of Firmware> <start|stop> [-mmap <memory_map_file>] [-i2c <0|1>]
    ===Mandatory arguments===
    <Processor Id> 0: DSP, 1: Video-M3, 2: Vpss-M3
    <Location of Firmware> firmware binary file
    <start|stop> to start/stop the firmware
    ===Optional arguments===
    -mmap input memory map bin file name
    -i2c 0: i2c init not done by M3, 1(default): i2c init done by M3
    FIRMWARE: isI2cInitRequiredOnM3: 1
    FIRMWARE: Default memory configuration is used
    Firmware Loader debugging not configured
    Default FL_DEBUG: warning
    Allowed FL_DEBUG levels: error, warning, info, debug, log
    MemCfg: DCMM (Dynamically Configurable Memory Map) Version : 2.1.2.1
    FIRMWARE: 2 start Successful
    VPSS_FVID2: M3 firmware version 0x1000145 is newer,driver may not work properly.
    HDMI W1 rev 2.0
    HDMI CEC Spec version 1.2
    I2C Bus Low?

    Starting system message bus: dbus.
    Starting telnet daemon.
    Starting syslogd/klogd: done
    Starting thttpd.
    Starting PVR
    Starting Matrix GUI application.

    _____ _____ _ _
    | _ |___ ___ ___ ___ | _ |___ ___ |_|___ ___| |_
    | | _| .'| . | . | | __| _| . | | | -_| _| _|
    |__|__|_| |__,|_ |___| |__| |_| |___|_| |___|___|_|
    |___| |___|

    Arago Project http://arago-project.org dm816x-evm ttyO2

    Arago 2011.09 dm816x-evm ttyO2

    dm816x-evm login: root



    Regards
    Fazil
  • Hello,

    You could ignore this message. You see it even if you are using the default firmware.

    Are you using the default encode demo ?

    If no, could you run the default omx demo.

    BR
    Margarita
  • Hi Margarita,

    I am not using omx demo.

    Could you please let me know, where I can find omx demo?

    Regards
    Fazil
  • Hello,

    You could find it in the FS /usr/share/ti/ti-omx

    BR
    Margarita
  • Hi Margarita,

    I could run omx demo with my old video firmware. But with the new video firmware, both my application and omx demo is giving below error


    root@dm816x-evm:/usr/share/ti/ti-omx# ./encode_a8host_debug.xv5T -o sample.mpg -
    i sample.yuv -f 30 -b 1000000 -w 320 -h 240 -c mpeg4
    output file: sample.mpg
    input file: sample.yuv
    bit_rate: 1000000
    frame_rate: 30
    codec: mpeg4
    width: 320
    height: 240
    Encode example
    ===============================
    OMX_Init completed
    UIAClient is ready to send a UIA configuration command
    UIAClient received UIA_CONFIGURE_ACK
    UIAClient is done sending requests
    UIAClient is ready to send a UIA configuration command
    UIAClient received UIA_CONFIGURE_ACK
    UIAClient is done sending requests
    opening file
    encoder component is created
    encoder input port allocate buffer done
    encoder outport buffers allocated
    got event*** unrecoverable error: OMX_ErrorBadParameter (0x80001005)
    Press a key to proceed


    Regards
    Fazil
  • Hello,

    I do not see this error. The only difference is that I use 1920x1080 resolution.

    BadParams error means one or more params were not valid.
    Could you start the UIA and attach the log?

    BR
    Margarita
  • Hi Margarita,

    Could you please let me know the procedure to start UIA?


    Regards
    Fazil
  • Hello,

    run ./loggerSMDump.out 0x9e400000 0x100000 all

    This is avilable at /usr/share/ti/ti-uia folder in filesystem.

    BR
    Margarita
  • Hi Margarita,

    I will check it and send the log by Monday.

    Thank you very much.

    Regards
    Fazil
  • Hi Margarita,

    Please find the logs attached.

    Logger1.txt - Log with already existing video frimware

    Logger2.txt - Log with modified video firmware.(Firmware which my application and omx demo does not run)

    Logger1.txtLogger2.txt

    I could not see any option to insert log file. So I used "rich formating" link which was found bottom left corner of "reply" box. 

    Regards

    Fazil

  • Hello,

    Here is my steps:

    I generate a yuv by gstreamer:

    gst-launch -v videotestsrc num-buffers=100 ! 'video/x-raw-yuv, width=1920, height=1080, format=(fourcc)NV12' ! filesink location=1.yuv

    I change the omx_mpeg4ve.c as is described in my previous post.

    I rebuild the HDVICP firmware and cp only it on sd card.

    I executed the encode demo :

    ./encode_a8host_debug.xv5T -o mpeg4.m4v -i 1.yuv -f 30 -b 4000000 -w 1920 -h 1080 -c mpeg4

    and it was working. In my case I had I frame on every 10th.

    In the debug log it seems that you are starting capture_ encode demo.

    Please could you try with default encode demo only?
    Rebuild overlay and cp HDVICP firmware.
    Use the default HDVPSS firmware.

    BR
    Margarita
  • Hi Margarita,

    Do I need to build video firmware with change for I-frame periodicity and copy both HDVICP and HDVPSS firmware from "component-sources/omx-ti81xx-src_05_02_00_48/bin/dm816xbm/bin/ti816x-evm/" directory?

    I ran below command for encode demo
    ./encode_a8host_debug.xv5T -o sample.mpg -i sample.yuv -f 30 -b 1000000 -w 320 -h 240 -c mpeg4

    Which is the default encode demo? Where I can find it?

    Regards
    Fazil
  • Hello,

    You could change omx_mpeg4ve.c file,  intraFrameInterval at line 726 and 878(with 10 for example and on 10th you should have an I frame) .

    Rebuild the overlay package (you could check in the ezsdk/doc folder EZSDK_Overlay_Installer_Build_Instructions.pdf guide).

    You should copy the new HDVICP firmware(but rename it first) in the sd card under /usr/share/ti/ti-media-controller-utils folder and replace dm816x_hdvicp.xem3 firmware. Boot the board.

    The encode demo is in /usr/share/ti/ti-omx, encode_a8host_debug.xv5T.

    BR

    Margarita

  • Hello Fazil,

    Are you able to rebuild the HDVICP firmware and execute the omx encode demo?

    BR
    Margarita
  • Hi Margarita,

    I am still not able to get this working.

    I  did like below as said in your previous mails.

    Made changes to omx_mpeg4ve.c file in line no : 726 and 878

    Rebuild overlay packege using make -f Overlay.Makefile

    Rename and copied HDVICP firmware to /usr/share/ti/ti-media-controller-utils

    Used default HDVPSS firmware, which was already in the board.

    When I sent you the logs for below command with modified HDVICP firmware

    ./loggerSMDump.out 0x9e400000 0x100000 all

    You said as per logs, It seems that I am using capture encode demo.

    And suggested to run default encode demo only?


    What are default encode demo and capture encode demo? Where can I find these two?

    Actually I ran below command for encode demo

    root@dm816x-evm:/usr/share/ti/ti-omx# ./encode_a8host_debug.xv5T -o sample.mpg -
    i sample.yuv -f 30 -b 1000000 -w 320 -h 240 -c mpeg4

    What is "encode_a8host_debug.xv5T"? Is it capture encode demo or default encode demo?

    Do I need to copy any other file or libraries related to the change in omx_mpeg4ve.c?

    Regards

    Fazil

  • Hello,

    encode_a8host_debug.xv5T this is the OMX encode demo.

    Mohammed Fazil said:
    Do I need to copy any other file or libraries related to the change in omx_mpeg4ve.c?

    No. You need the rebuilt dm816x_hdvicp.xem3 only.

    BR
    Margarita

  • Hi,

    Thank you very much for the support.

    I will check it again from the begining. I will ping you after that.

    Once again thank you.

    Regards
    Fazil