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.

Dumped .h264 file is not proper in capture_encode demo of EzSDK5_05

Hi,

I am using EzSDK5.05 for DM8148 EVM. I am trying to run capture_encode demo given with EzSDK. I gave following parameters for 720p60 input source,

./capture_encode_a8host_debug.xv5T -o sample.h264 -m 720p -f 60 -b 1000000 -d 0 -n 1000

I can see display on my LCD connected with on chip HDMI and it's working well. But when I run dumped .h264 encoded file in VLC player, it plays video very slow. It shows 30 fps instead of 60fps.

I am using high profile with level 4.2. I have verified bellow parameters for input and output encoder port,

tPortDef.nPortIndex = OMX_VIDENC_INPUT_PORT;

tPortDef.nBufferCountActual = IL_CLIENT_ENC_INPUT_BUFFER_COUNT;

tPortDef.format.video.nFrameWidth = pAppData->nWidth;

tPortDef.format.video.nStride = pAppData->nWidth;

tPortDef.format.video.nFrameHeight = pAppData->nHeight;

tPortDef.format.video.eColorFormat = OMX_COLOR_FormatYUV420SemiPlanar;

tPortDef.nBufferSize = (pAppData->nWidth * pAppData->nHeight * 3) >> 1;

eError = OMX_SetParameter (pHandle, OMX_IndexParamPortDefinition, &tPortDef);

tPortDef.nPortIndex = OMX_VIDENC_OUTPUT_PORT;

tPortDef.nBufferCountActual = IL_CLIENT_ENC_OUTPUT_BUFFER_COUNT;

tPortDef.format.video.nFrameWidth = pAppData->nWidth;

tPortDef.format.video.nFrameHeight = pAppData->nWidth;

tPortDef.format.video.eCompressionFormat = OMX_VIDEO_CodingAVC;

tPortDef.format.video.xFramerate = (pAppData->nFrameRate << 16);

tPortDef.format.video.nBitrate = pAppData->nBitRate;

eError = OMX_SetParameter (pHandle, OMX_IndexParamPortDefinition, &tPortDef);

So what would be the issue with dumped .h264 encoded file ?

I have also tried changing frame rate to -f 10, -f 15, -f 30, -f 60, -f 120 but Dumped .h264 file shows 30fps video only every time when i play it into VLC player.

It seems OMX_SetParameter API hard coded the frame rate value. Is it so ?

Seeking quick response.

Thanks in advance,

Shabbir Limdiwala

  • Hi,

    Any update on above post ?

    Shabbir Limdiwala

  • Hi,

    Any update on above post ?

    Shabbir Limdiwala

  • Hello,

    Could you increase the bitrate to 10 000 000 (-b 10000000) and let me know the result.

    Best Regards,

    Margarita

  • Hi Margarita,

    I have tried this (./capture_encode_a8host_debug.xv5T -o sample.h264 -m 720p -f 60 -b 10000000 -d 0 -n 1000). But I am getting the same result. H264 file is still not proper.

    Thanks,

    Shabbir Limdiwala

  • Hello Shabbir,

    Maximum bit rate depends upon the level setting. This version supports
    the maximum bit rate of 50 mbps (Base Line and Main profile Level 4.2)
    and 62.5 mbps (High Profile Level 4.2) for 30 fps case.

    refer to: ti-ezsdk_dm814x-evm_5_05_01_04/component-sources/omx_05_02_00_46/src/ti/omx/docs

    H264_Encoder_HDVICP2_UserGuide.pdf

    You could try to change the profile's level.

    Best Regards,

    Margarita

  • Hi Margarita,

    It is still playing with slow frame rate. I didn't see any change when I changed profile, level and bit rate.

    I used High profile with level 4.2.

    I have varied bit rate from 1 Kbps to 62.5 Mbps. But the result is same.

    Shabbir Limdiwala

  • Hello Shabbir,

    Can you attach this video?

    Best Regards,

    Margarita

  • Hi Margarita,

    Please find attached "sample.h264.txt" here with this post. ".h264" file format was not allowed for upload so renamed it with sample ".txt" remove that extension. 4062.sample.h264.txt

    Kind Regards,

    HiteshV.

  • Hello,

    Could you verify this is correct:

    tPortDef.nBufferCountActual = IL_CLIENT_ENC_OUTPUT_BUFFER_COUNT;

    tPortDef.format.video.nFrameWidth = pAppData->nWidth;

    tPortDef.format.video.nFrameHeight = pAppData->nWidth;

    tPortDef.format.video.eCompressionFormat = OMX_VIDEO_CodingAVC;

    or it should be nHeight?

    Best Regards,

    Margarita

  • Hello,

    I check the video with mplayer and it reported: "FPS not specified in the header or invalid". The other player report framerate 0.

    The VLC set framerate by default 30 fps.

    Best Regards,

    Margarita

  • Hello Margarita,

    I have verified all the encoder configuration parameters that you mentioned in above thread. The posted parameters were older and we have modified and the updated parameter is tPortDef.format.video.nFrameHeight = pAppData->nHeight; only, which it must be.

    I booted up the board with the default uImage and filesystem that comes inside ezsdk_05_05 and ran the same "capture_encode" demo. And i am on the same page with the default uImage, filesystem and capture_encode application binary that comes as pre-built binaries.

    It seems that there is some minor mistake but we are unable to figure it out. Can you please highlight on this ?

    Regards,

    HiteshV

  • Hello,

    What is the EZSDK release, that you are using?

    What is the OMX version?

    Did you changed the source code(capture_encode demo) somehow?

    Best Regards,

    Margarita

  • Thanks for a prompt reply.

    We are using EZSDK release "ezsdk_dm814x-evm_5_05_01_04" and OMX version that comes with it is "omx_05_02_00_46"

    I didn't changed a single line code when i am saying i ran default demo.It has encoder parameters as below (it is taking MAX width and MAX height):

      tPortDef.format.video.nFrameWidth = IL_CLIENT_ENC_WIDTH;
      tPortDef.format.video.nStride = IL_CLIENT_ENC_WIDTH;
      tPortDef.format.video.nFrameHeight = IL_CLIENT_ENC_HEIGHT;

    With the above default app encoded video doesn't have even 30fps, rather it is blocky video you can say.

    And yes, then i modified the demo as per the input resolution given by the user while running the demo: ./capture_encode_a8host_debug.xv5T -o sample.h264 -m 720p -f 60 -b 1000000 -d 0 -n 1000

    I assigned above parameters according to 720p video resolution. With this I got 30 fps but still not 60 fps which is desired to be. And then did all the bit-rate parameter changes suggested by you but we didn't make any progress on it.

    Regards,

    HiteshV

  • Hello,

    Could you run the capture_encode demo without any modification.

    This application takes mode (1080p/720p), frame rate, bitrate and file name as input argument. By default display is on on-chip HDMI port. Encoder bit rate can be varied through arguments passed in the application. More parameters for encoding can be changed in IL client though OMX APIs. Capture is always at 60 fps, irrespective of frame rate specified. If it is set to 30 capture component would skip frames as per mask specified in example, and provide 30 frames to encoder. So the source should provide 60fps.

    It should be work for 720p60.

    Refer to: http://processors.wiki.ti.com/index.php/OMX_EZSDK_Examples#Capture_Encode

    and let me know the result.

    The frame rate of the attached video is missing. The mplayer reported: "FPS not specified in the header or invalid". The other video players reported framerate 0. When you play it with the VLC, the VLC set frame rate 30 fps by default.

    Best Regards,

    Margarita

  • Hi,

    I ran the capture_encode demo without any modification. I performed below steps:

    root@dm814x-evm:~# cd /home/root/dm814x-evm/usr/share/ti/ti-omx/
    root@dm814x-evm:~# ./capture_encode_a8host_debug.xv5T -f 60 -m 1080p -b 6000000 -o sample.264 -n 1000 -d 0

    I played the h264 dumped file, but it shows only first frame and it freezes till the end.

    I also run the same demo with 720p as well with below commands:

    root@dm814x-evm:~# cd /home/root/dm814x-evm/usr/share/ti/ti-omx/
    root@dm814x-evm:~# ./capture_encode_a8host_debug.xv5T -f 60 -m 720p -b 6000000 -o sample.264 -n 1000 -d 0

    I played the h264 dumped file, I change VLC settings. I updated default VLC frame-rate to 60 fps as my encoder has encoded dumped data at 60 FPS.  And this worked for me in case of 720p only, but still 1080p is not working as mentioned above.

    I am confused, why frame rate is missing into the dumped file ?? ( I have to update VLC frame-rate manually to render it at proper frame-rate).

    Now i have one clue for 1080p encoding not working properly (i mean to say here is, only first frame and then it freezes till end), Is default HDVICP2 clock is capable of encoding 1080p resolution ? If not so, can you let me know where in u-boot (or somewhere else if required) i need to change to make HDVICP2 running at max clock so as to encode 1080p resolution properly ?

    Thanks,

    HiteshV

  • Hello Margarita,

    Any updates/comments on above observation ?

    Regards,

    HiteshV

  • Hi Margarita,

    The problem seems to be that the H264 encoder is not setting the fps field correctly. Can you please check with our codec team and get back please?

    Thnaks & best Regards

    Feroz

  • Hi Margarita,

    Please see more inputs here from the customer:

    Some input (observation) on this demo:

    1. With few changes (we just removed some hard coding of encoder parameters like width, height and stride) our capture_encode demo works fine with 720p60 input (capture) resolution (and encoder encoding @ 60 fps).
    2. But in case of 1080p60 and 1080i60 input (capture) resolution capture_encode demo (and encoder encoding @ 60 fps) doesn't work properly i.e. VLC can decode initial 3 to 4 blocks only and then it shows the same frame where it blocked.
    3. But in case of 1080p60 and 1080i60 input (capture) resolution capture_encode demo (and encoder encoding @ 30 fps) works fine i.e. By setting VLC H264 demuxer (with 30 fps) it can decode all the frames very well, and it doesn't blocked.

    Can you please let us know what can be the issue ?
    Is this issue of HDVICP2 running slow ? If so, can you guide us how can we make HDVICP2 running at MAX speed.

    FYI : We also tried with the default capture_encode demo but the is the case there as well.

    Best Regards

    Feroz

  • Hello,

    "2. But in case of 1080p60 and 1080i60 input (capture) resolution capture_encode demo (and encoder encoding @ 60 fps) doesn't work properly i.e. VLC can decode initial 3 to 4 blocks only and then it shows the same frame where it blocked."

    In this case when you decode it on the board is it works fine with 60 fps (with default capture_encode demo)?

    Best Regards,

    Margarita

  • Hi Margrita,

    When i decode it on the board using decode_display demo it doesn't decode and display properly i.e. it shows half of the previous frame into current frame display (i can say it shows many macro-blocks are there), i can say on board decoder can decode all the frames but with the problem as i specified. (slightly better performance then VLC software decoder)

    In addition to that if i encode it @ 30 fps and decode it @ 30 fps, works fine for me with EVM encoder. This is with the default demo as well as the demo i updated.

    Regards,

    Hitesh

  • Dear Teams,

    Please see the discussion below on the frame rate field setting. 

    For the frame rate related issue please see inputs from our team:

    Frame rate is part of VUI not SPS/PPS. In RDK we configure encoder to output VUI info but this is most probably not done in EZSDK. I don’t think there is any configuration option.

     

    [Hitesh]: Encode only demo in EZSDK already uses OMX_VIDEO_PARAM_STATICPARAMS structure which sets encodingPreset and rateControlPreset in IVIDENC2_Params parameters using OMX_GetParameter/OMX_SetParameter APIs. As per your suggestions, I added below code along with the existing above settings but i didn't get Frame rate information.

      OMX_INIT_PARAM (&tStaticParam);
      tStaticParam.nPortIndex = OMX_VIDENC_OUTPUT_PORT;

      eError = OMX_GetParameter (pHandle, OMX_TI_IndexParamVideoStaticParams, &tStaticParam);

      tStaticParam.videoStaticParams.h264EncStaticParams.rateControlParams.HRDBufferSize = pAppData->nBitRate * 2;
      tStaticParam.videoStaticParams.h264EncStaticParams.videnc2Params.encodingPreset = XDM_DEFAULT;
      tStaticParam.videoStaticParams.h264EncStaticParams.videnc2Params.rateControlPreset = IVIDEO_STORAGE;
      tStaticParam.videoStaticParams.h264EncStaticParams.nalUnitControlParams.naluControlPreset = IH264_NALU_CONTROL_USERDEFINED;
      ENCLINK_H264_SETNALU_MASK_SPS(tStaticParam.videoStaticParams.h264EncStaticParams.nalUnitControlParams.naluPresentMaskIntraPicture);
      ENCLINK_H264_SETNALU_MASK_PPS(tStaticParam.videoStaticParams.h264EncStaticParams.nalUnitControlParams.naluPresentMaskIntraPicture);
      ENCLINK_H264_SETNALU_MASK_SPS(tStaticParam.videoStaticParams.h264EncStaticParams.nalUnitControlParams.naluPresentMaskIDRPicture);
      ENCLINK_H264_SETNALU_MASK_PPS(tStaticParam.videoStaticParams.h264EncStaticParams.nalUnitControlParams.naluPresentMaskIDRPicture);
      ENCLINK_H264_SETNALU_MASK_SEI(tStaticParam.videoStaticParams.h264EncStaticParams.nalUnitControlParams.naluPresentMaskIDRPicture);
      ENCLINK_H264_SETNALU_MASK_SPS(tStaticParam.videoStaticParams.h264EncStaticParams.nalUnitControlParams.naluPresentMaskStartOfSequence);
      ENCLINK_H264_SETNALU_MASK_PPS(tStaticParam.videoStaticParams.h264EncStaticParams.nalUnitControlParams.naluPresentMaskStartOfSequence);
      ENCLINK_H264_SETNALU_MASK_SEI(tStaticParam.videoStaticParams.h264EncStaticParams.nalUnitControlParams.naluPresentMaskStartOfSequence);
      tStaticParam.videoStaticParams.h264EncStaticParams.vuiCodingParams.vuiCodingPreset = IH264_VUICODING_USERDEFINED;
      tStaticParam.videoStaticParams.h264EncStaticParams.vuiCodingParams.hrdParamsPresentFlag = 1;
      tStaticParam.videoStaticParams.h264EncStaticParams.vuiCodingParams.timingInfoPresentFlag = 1;

      eError = OMX_SetParameter (pHandle, OMX_TI_IndexParamVideoStaticParams,
                                 &tStaticParam);
    The openMax encoder code has to be modified. Also I don’t think openMax encoder has any API to configure the target frame rate so a new API has to be added.

    [Hitesh]: Encode only demo already does target frame rate settings using OMX_VIDEO_CONFIG_DYNAMICPARAMS structure shown in below code but still it doesn't set 60 fps (it shows 30 fps only)
      OMX_INIT_PARAM (&tDynParams);
      tDynParams.nPortIndex = OMX_VIDENC_OUTPUT_PORT;

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

      /* setting I frame interval */
      tDynParams.videoDynamicParams.h264EncDynamicParams.videnc2DynamicParams.targetFrameRate = pAppData->nFrameRate * 1000;
      tDynParams.videoDynamicParams.h264EncDynamicParams.videnc2DynamicParams.targetBitRate = pAppData->nBitRate;
      tDynParams.videoDynamicParams.h264EncDynamicParams.rateControlParams.rateControlParamsPreset = IH264_RATECONTROLPARAMS_DEFAULT;
      tDynParams.videoDynamicParams.h264EncDynamicParams.rateControlParams.HRDBufferSize = pAppData->nBitRate * 2;
      tDynParams.videoDynamicParams.h264EncDynamicParams.videnc2DynamicParams.intraFrameInterval = 90;

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

    Add the following code to set the H264 static parameter.  This will generate the correct SPS/PPS and VUI headers

     

    #define ENCLINK_H264_SETNALU_MASK_SPS(naluMask) ((naluMask) |= (1 << IH264_NALU_TYPE_SPS_WITH_VUI))

    #define ENCLINK_H264_SETNALU_MASK_PPS(naluMask) ((naluMask) |= (1 << IH264_NALU_TYPE_PPS))

    #define ENCLINK_H264_SETNALU_MASK_SEI(naluMask) ((naluMask) |= (1 << IH264_NALU_TYPE_SEI))

     

        /* We want SPS and PPS to be set for every intra frame. Hence configure the

         * the NALU control params to force encoder to insert SPS/PPS on every

         * I frame

         */

        staticParams->nalUnitControlParams.naluControlPreset =

                                                 IH264_NALU_CONTROL_USERDEFINED;

        ENCLINK_H264_SETNALU_MASK_SPS(staticParams->nalUnitControlParams.

                                                    naluPresentMaskIntraPicture);

        ENCLINK_H264_SETNALU_MASK_PPS(staticParams->nalUnitControlParams.

                                                    naluPresentMaskIntraPicture);

     

        ENCLINK_H264_SETNALU_MASK_SPS(staticParams->nalUnitControlParams.

                                                    naluPresentMaskIDRPicture);

        ENCLINK_H264_SETNALU_MASK_PPS(staticParams->nalUnitControlParams.

                                                    naluPresentMaskIDRPicture);

        ENCLINK_H264_SETNALU_MASK_SEI(staticParams->nalUnitControlParams.

                                                    naluPresentMaskIDRPicture);

     

        ENCLINK_H264_SETNALU_MASK_SPS(staticParams->nalUnitControlParams.

                                                    naluPresentMaskStartOfSequence);

        ENCLINK_H264_SETNALU_MASK_PPS(staticParams->nalUnitControlParams.

                                                    naluPresentMaskStartOfSequence);

        ENCLINK_H264_SETNALU_MASK_PPS(staticParams->nalUnitControlParams.

                                                    naluPresentMaskStartOfSequence);

     

    I think some portion of the above setting is also available with OMX; you can replace the existing SPS/PPS setting with above

     

         /* To insert VUI parameters in the header */

        staticParams->vuiCodingParams.vuiCodingPreset = IH264_VUICODING_USERDEFINED;

        staticParams->vuiCodingParams.hrdParamsPresentFlag = 1;

        staticParams->vuiCodingParams.timingInfoPresentFlag = 1;

     

     

    Set targetFrameRate in dynamicParams to set the initial frame rate, this can be set before create time (I think this is already present in OMX code)

     

    [Hitesh]: Yes, this is present in Encode only demo, but didn't set frame-rate to 60 fps.
     

    As Badri mentioned, you need to add a run time API to set the frame rate if you want to change the frame rate dynamically.  

     

    Refer, encLink_h264.c of DVR RDK for details

     

    Thanks.

    Best Regards,

    Feroz

  • Hi Team,

    Updates from Hitesh:


    We never get fps other then 30 in case of encode only demo irrespective of whatever fps value we set at creation time or run-time using dynamic parameters.

    During experiments, when i set I-Frame interval as 1 i.e. All the encoded frames will be I-Frames only in capture_encode demo, and i played the encoded file (obviously with much higher size) with mplayer, it plays it smoothly (Here encoder would not be fully utilized).
    And when i start increasing I-Frame interval (i.e. start adding P-Frames), My encoder doesn't give me P-Frame as output or partial data (garbage) many times (instead it gives me blank frame) as a result when i play it in mplayer it just shows the I/P Frame which was last frame (Garbage video or macro-blocks when there is empty or partial data) that was generated by encoder.

    Is above two points conclude that "Encoder is fully utilized" ?

    I also tried increasing ARM, DDR and IVA (HDVICP2) clock to 720MHz, 480MHz and 410MHz respectively.

    Best Regards

    Feroz

  • Hello All,

    One update from my side, "1080p60 working perfectly with capture_encode demo in ezsdk" but still remaining issue is "Encode only demo encodes at 30 fps irrespective of any fps of encoder we set."

    Regards,

    Hitesh

  • Hello TI,

    You can close this thread now. I found fix for "Encode only demo encodes at 30 fps irrespective of any fps of encoder we set." as well.

    It was only possible from your help only. Many thanks for all your efforts.

    Special thanks to Feroz (TI FAE for us), who was continuously supporting me with different inputs.

    Regards,

    Hitesh