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.

H264 Bit Rate / Quality Settings (DM6467)

hello,

I am using the Video Encoding h264enc 720p h264 base profile video encoder version 1.20.02 for the dm6467t.  I am having a problem with bit rate.  I need to keep the bit rate low but I can seem to do that without generating lots of zero frames.

For example, if I have a stream of 720x480 images at a frame rate of 8fps then I need to average about ~12000 bytes for each encoder frame.  However, if ask for a bit rate of something that should be able to handle this like 800000 bits, I often see that a single frame will take up almost the entire bit count and then the rest of the frames in that second will end up being zero frames or skipped.

I can't seem to understand how best to configure my codec to do what I want.  The I frames can take up more of the bit rate, but I can't have this many skipped frames.

I found this link for a different component:

http://processors.wiki.ti.com/index.php/DM36x_Rate_Control_Modes

Is there a similar link for dm6467?  How can I best control the bitrate for the encoder?  What are my options?

Thanks,

Brandy

 

  • Hi Brandy,

    I will come back on this probably on Monday.

    Regards,

    Mahantesh

  • ok thanks.  Is there any more information you need?

  • Hello again Mahantesh,

    Thanks for your support.  I would like to add another query, is it possible to add HRD sequence to this encoder?  If it cannot support this automatically, how could I do it from the application side?  Is there any information I could use about this SEI (Supplemental Enhancement Information) to manually create this data to send with the SPS/PPS headers?  I am see that the decoders are not able to properly decode becuase my frame rate is much smaller than 30 fps.

    Brandy

  • Hi Brandy,

    1. To avoid many frame skips can you try with using VBR mode of RC and please check your QP values as well. No similar docs were available for DM6467 codecs.

    2. The encoder generates the bits stream which is conforming to NAL unit stream.

    But, your following query is not clear, can you please put in other words,

    is it possible to add HRD sequence to this encoder?

    Regards,

    Mahantesh

  • Hi Mahantesh,

    Thanks for not forgetting about me :)

    First let me comment on your comments, then I will share with you my progress.

    1.  I cannot use VBR becuase then there is not enough compression of image.  What I mean is, the output buffer size is too large and I can not effectively stream the video image.

    2.  I have used a buffer analyzer and can see that the NAL units are correct but they are limited.  There is a SPS/PPS only with IDR frames and slice header with every frame.

    What I need are timing NAL units.  There is someting called the VUI parameters inside the SPS.  If you enable this flag, then a lot of timing options are available, including the NAL_HRD paramters and the VLC_HRD parameters.  Once these are enabled in the SPS then you can use the SEI message pic_timing and buffer_period.

    Since we last chatted, I was able to correctly format my own version of the SPS, PPS and various SEI messages manually.  I am no longer using the headers that are generated by the encoder.  I merely overwrite them with my SPS/PPS and the additional data.

    However, now I am struggle to determine what values to place in these message pic_timing and buffer_period.  I have looked at the H264 specification but it is difficult to decode.  Do you have any expertise in this subject now that I have explained it more?  What should the values be in the cpb_removal_delay and the dpb_output_delay?  Perhaps a collegue from the DM365 codec team could help since they seem to have done this already inside their codec?

    Here what my headers look like right now.  Sorry about the formatting.

    Thanks for your help,

    Brandy

    _________________________________________________________________________________________________________

       [00]seq_parameter_set_rbsp() {
        profile_idc                                    = 66 (Baseline)
        constraint_set0_flag                           = 1 (true)
        constraint_set1_flag                           = 0 (false)
        constraint_set2_flag                           = 0 (false)
        constraint_set3_flag                           = 0 (false)
        reserved_zero_4bits                            = 0 (false)
        level_idc                                      = 40
        seq_parameter_set_id                           = 0
        if (profile_idc == 100 || profile_idc == 110 || profile_idc == 122 || profile_idc == 144) {
        log2_max_frame_num_minus4                      = 0 (4)
        pic_order_cnt_type                             = 0
        if (pic_order_cnt_type == 0)
        else if (pic_order_cnt_type == 1) {
        num_ref_frames                                 = 1
        gaps_in_frame_num_value_allowed_flag           = 0
        pic_width_in_mbs_minus1                        = 44 (720)
        pic_height_in_map_units_minus1                 = 29 (480)
        frame_mbs_only_flag                            = 1
        if (!frame_mbs_only_flag)
        direct_8x8_inference_flag                      = 0 (false)
        frame_cropping_flag                            = 0 (false)
        if (frame_cropping_flag) {
        vui_parameters_present_flag                    = 1 (true)
        if (vui_parameters_present_flag)
          vui_parameters() {
            aspect_ratio_info_present_flag             = 0 (false)
            if (aspect_ratio_info_present_flag) {
            overscan_info_present_flag                 = 0 (false)
            if (overscan_info_present_flag)
            video_signal_type_present_flag             = 1 (true)
            if (video_signal_type_present_flag) {
            chroma_location_info_present_flag          = 0 (false)
            if (chroma_loc_info_present_flag) {
            timing_info_present_flag                   = 0 (false)
            if (timing_info_present_flag) {
            nal_hrd_parameters_present_flag            = 1 (true)
            if (nal_hrd_parameters_present_flag)
              nal_hrd_parameters() {
                cpb_cnt_minus1                         = 0 (1)
                bit_rate_scale                         = 1
                cpb_size_scale                         = 3
                for (SchedSelIdx = 0; SchedSelIdx <= cpb_cnt_minus1; SchedSelIdx++) {
                initial_cpb_removal_delay_length_minus1 = 23
                cpb_removal_delay_length_minus1        = 22
                dpb_output_delay_length_minus1         = 22
                time_offset_length                     = 0
                }
              }
            vcl_hrd_parameters_present_flag            = 1 (true)
            if (vcl_hrd_parameters_present_flag)
            if (nal_hrd_parameters_present_flag || vcl_hrd_parameters_present_flag)
            pic_struct_present_flag                    = 0 (false)
            bitstream_restriction_flag                 = 0 (false)
            if (bitstream_restriction_flag) {
            }
          }
        }
      [00]pic_parameter_set_rbsp() {
      [00]slice_header() {
      [00]sei() {                                      = 35
      [01]sei() {                                      = 20
        buffering_period() {
          seq_parameter_set_id                         = 0
          if (NalHrdBpPresentFlag) {
            for (SchedSelIdx = 0; SchedSelIdx <= cpb_cnt_minus1; SchedSelIdx++) {
              initial_cpb_removal_delay[00]            = 9000
              initial_cpb_removal_delay_offset[00]     = 0
              }
            }
          if (VclHrdBpPresentFlag) {
          }
        }
      [02]sei() {                                      = 14
        pic_timing() {
          if (CpbDpbDelaysPresentFlag) {
            cpb_removal_delay                          = 0
            dpb_output_delay                           = 0
            }
          if (pic_struct_present_flag) {
          }
        }

     

  • Hi Brandy,

    Can you please, specify your use cases or config parameters used, so that it will be easy to recomend for VUI and SEI messages.

    Regards,

    Mahantesh

     

  • Sure.  My video stream is expected to be at 8fps.  The quality values are set to default and I am using CBR set to 800,000.  I need to keep the compressed frame size to around 12000 bits for a 720x480 frame.

    I am currently starting to think about extending the encParams struct to expose the quality parameters to see if I can figure out how to decrease the quality a bit and so that the encoder will produce fewer zero byte frames.

  • Hello,

    I'm using dm6467 to encode video in h264.

    I have also a similar problem.

    My contraints are:

     

    video CBR, 128000 bps ( very low), with an IDR frame every second ( framerate 30fps ).

    How can I configure the encoder to avoid frame skip?

     

    With dm365 I had not problems, but dm6467 seems to have a poor bitrate control, right?

     

    Thanks

    Claudio

     

  • Hi Claudio,

    I have had a thought to try to extend the parameters as described with the IH264VENC_DynamicParameters.  I have not yet had a chance.  I hoping with these extended parameters that we could control the quality a bit better and be able to tell the codec to produce less quality in order to share the bits better across the stream.

    If I find that some parameter set is working, I will post it for you.  Perhaps you could also hint if you get to it before me.

    Also, I find that TI tends to ignore older posts - you might be better off starting a new post and I will suscribe to your post to see if they respond with some ideas for you.

    Good luck!

    Brandy

  • Hi!

    Working on the extended parameters seems to produce some result.

    QPISlice, QPSlice, RateCtrlQpMax and  RateCtrlQpMin are the involved parameters.

    So, depending on the bitrate required ( in CBR mode),  I set different value of these QP params.

     

     

    Good luck!
    Claudio

  • Hi,

    Hope your problem get resolved, thanks for each other's help. Please get back if you have any other issues. TI will never ignore to reply the queries, however there might be some delay if we are busy with some other urgent tasks.

    Regards,

    Mahantesh  

  • Hello Mahantesh,

    Quantitation parameters seems to help to avoid frame skip in CBR.

    However, the constant bitrate is really an issue when IDR frames are forced ( like 1 every 30 frames ).

    For me is really a problem, I need a good CBR at low bitrate, forcing 1 IDR every 30-60 frames.

     

    Do you have any suggestion?
    Please help

    regards.

    PS: any chance to have control bitrate like dm365?

     

     

  • Hello Mahantesh,

    This is the problem I see too.  It is inevitable that when I have to generate an IDR frame that there will be zero frames surronding it.  I also need a good, low CBR while still forcing IDR frames every 60 frames.

    Thanks,
    Brandy

  • Hi Guys,

    I will probably come back on this on Monday.

    Regards,

    Mahantesh

     

  • Thanks Mahantesh,

    waiting for your answer,

     

    nice weekend!

    claudio

  • Hi Brandy, Claudio,

    Can you please share the current config parameter info including input resolution, bit rate etc, this looks a quality issue based on different config params. Based on these info we will come back on this.

    Regards,

    Mahantesh

      

     

  • Hello Mahantesh,

    You can see my settings from my post on 9/6.  If you need more specifics than this, I can look up the exact variable names in the code tomorrow.

    Thanks,

    Brandy

  • Hello mahantesh,

    I can send my settings tomorrow but I'm note sure it is a setting issue.

    in my opinion, it seems that the problem is the IDR forcing action.

    The control rate algorithm cannot know when the IDR will be forced, so cannot "reserve" space and control the bitrate with enough precision.

     

    Could be?

     

    Regards

    Claudio

     

     

  • Hello Mahantesh,

    do you have any news? could you please help us to know if there's a solution or nothing can be done?

    Just to take a decision on our side

    Thasnk and regards

    Claudio

  • Hello TI and Mahantesh,

     

    This is quite ridiculous.  This discussion has been open since September and there is still no answer.  It is a very simple question.  Why, when using CBR, do we get so many zeros frames when IDR frame is forced?  Like Claudio said, this is not the same behavoir as other algorithms.  I need to know a solution.

     

    Thanks,
    Brandy

  • Hi Brandy,

    Sorry for the delayed response, since it was a vacation time during last week of Dec 2011.

    We are analyzing this quality issue and definitely we will provide the workaround for this.

    Regards,

    Mahantesh

     

  • Thanks Mahantesh.  Please let me know if I can help with anything, especially if it might speed things up.

     

    Brandy

  • Hi Brandy,

    did you have any news about this issue?

    thanks

    Claudio

  • I have heard nothing on this front.

     

    I would recommend starting a new thread and trying to get someone else's attention.  And if they tell you its a duplicate thread, give a hard time :)

     

    Brandy

  • Hi Brandy,

    I don't if it's the good anwser but :

    With the h264fhdvenc there is a dynparams "max delay" which is in relation with the VBV (look on net for info) in CBR mode.

    When i use a low bitrate at output + low max delay with a high complexity (lot of mouvement) stream the encoder generates 0 bytes (can't encode in the max delay time).

    In the h264enc there is no params like that but it's in the h264 norme (near to be sure) so maybe i could be your problem.

    What i want to say, it's try to use h264fhdenc with a great max delay Dynparams and decrease your bitrate.

    (it could be that the resolution (if you are using D1) of your input it's not compatible :-/).

    Hope  it help.

    Mika

  • Brandy

    After analyzing and discussion at our end we came to know that, due to the known current RC algorithm limitations in the encoder the frames are skipped after an IDR frame for this type of low bit rate encoding. So, this is an encoder limitation.

    Regards,

    Mahantesh

     

  • Hello Mahantesh,

    Can you please explain more about the problem?  What do you mean by RC algorithm limitation?  RC to mean means Resistance/capacitance circuit - so it is a hardware problem? or is this something that we can look into and fix via the source code? 

    Please advise.  There must be some fix.

    Thanks,
    Brandy

  • Hi Brandy,

    RC should be the Rate Control algorithm.

    To avoid frame skip issue I'm using VBR (Variable Bit Rate) instead of CBR (Constant Bit Rate) algorithm, but the bit rate is too variable for my application :/

    Regards

    Claudio

  • Yes, VBR is definitely not an option for me.  I have a very limited downlink.

    Hopefully Mahantesh can suggest something else.

     

    Brandy

  • Hi Brandy,

    regarding your first questions about SEI messages..

    Did you find a solution about what values must be placed in pic_timing (cpb_removal_delay and dpb_output_delay) and buffer period message?

    I have to add them manually ( I miss dm365 ... :/ )

    thanks

    claudio

  • Hello Claudio,

    I am sorry, in the end I abandoned the pic_timing message in favor of the fixed frame rate bits in the SPS message.  I played around with the values several times in the pic_timing and was not able to get a better flow from the decoder.  Perhaps VLC was not using these messages so that is why it did not help or perhaps I never found the right implementation etc.  When I told VLC that the stream was a fixed frame rate, gave it a UTC time stamp (close to the frame rate) and the expected frame rate the viewing was much smoother.  this was all in the SPS message.

    Although, still no update on the zero frames.  Disappointing, but we are code frozen now so it was it is for me.

    Ciao!

    Brandy

  • Hi Brandy,

    thanks for your fast reply !

    For me it is mandatory to have those informations in the bitstream. :/

    Yes, no way to have a solution in CBR mode. Using VBR method, but it is not a good solution for me.

    Regards!

    claudio