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.

HF-VBR (CVBR) Rate Control Configuration

Hi all,

I'm trying to get HF-VBR rate control working on DM8127/DM8148 with H264 codec version 2.0.2.2.

When I configure the rate control as user-defined and set the target and max bitrates these don't get applied by the encoder. For the example parameters below, I set the target bitrate to 2Mb and max bitrate to 3.2Mb but the video is streamed at around 3.5-4Mb.

I've tried various bitrates and parameter combinations according to H264_Encoder_HDVICP2_UserGuide.pdf and suggested by other threads on the forum with no success..

Does anyone have experience of HF-VBR working with this codec version?

Any help would be much appreciated!

Thanks,
William.

rateControlPreset = 5 (USER_DEFINED)
targetBitRate = 2000000
maxBitRate = 3200000

rateControlParamsPreset = 1 (USER_DEFINED)
scalingMatrixPreset= 1
rcAlgo = 0
qpI = 28
qpMaxI = 36
qpMinI = 10
qpP = 28
qpMaxP = 40
qpMinP = 10
qpOffsetB = 4
qpMaxB = 44
qpMinB = 10
allowFrameSkip = 0
removeExpensiveCoeff = 0
chromaQPIndexOffset = 0
IPQualityFactor = 0
initialBufferLevel = 4000000
HRDBufferSize = 4000000
minPicSizeRatioI = 0
maxPicSizeRatioI = 640
minPicSizeRatioP = 0
maxPicSizeRatioP = 0
minPicSizeRatioB = 0
maxPicSizeRatioB = 0
enablePRC = 1
enablePartialFrameSkip = 0
discardSavedBits = 0
reserved = 0
VBRDuration = 8
VBRsensitivity = 0
skipDistributionWindowLength = 5
numSkipInDistributionWindow = 1
enableHRDComplianceMode = 1
frameSkipThMulQ5 = 0
vbvUseLevelThQ5 = 0
reservedRC[0] = 0
reservedRC[1] = 0
reservedRC[2] = 0

 

  • Hello,

    Could you try to set:

    rateControlPreset = IVIDEO_STORAGE

    or

    william calvert said:
    rateControlParamsPreset = 1 (USER_DEFINED)

    rcAlgo = 0

    rateControlPreset = IVIDEO_USER_DEFINED
    rcAlgo = IH264_RATECONTROL_PRC

    and

    maxBitRate >= (1.5 x targetBitRate )

    VBRsensitivity parameter is also applicable to HF-VBR: High Fidelity Variable Bitrate. It controls the
    sensitivity of the HF-VBR algorithm towards the complexity of video. It can take any value
    from 0 to 8. A lower value signifies that maxBitrate will be used for very complex scene, in
    case complexity increase is not high, HF-VBR will choose a bitrate between target bitrate and
    maxBitrate. If set to higher value say 8, rate control tries to achieve maxBitrate even for small
    complexity increase.


    Let me know the result.

    Best Regards,

    Margarita

  • Hi Margarita - thanks for the reply!

    I tried setting rateControlPreset=IVIDEO_USER_DEFINED, rcAlgo=1 (see params below) but this didn't seem to make any difference.

    I tested with targetBitRate=500Kb and maxBitRate=1500Kb but the bitrate increases greater than 2500Kb when there is a lot of motion in the video. I am measuring the bitrate using vlc and wireshark.

    I also tried rateControlPreset = IVIDEO_STORAGE with similar results.

    I also moved to a later encoder release 2.0.4.1 (from IPNC RDK 3.5).

    My understanding is that the bitrate should not exceed the maxBitRate setting even for a complex scene with a lot of motion - is this correct?

    Regards,

    William.

    Params:

    encodingPreset=3
    rateControlPreset=5
    targetBitRate=500000
    rateControlParamsPreset = 1
    scalingMatrixPreset= 1
    rcAlgo = 1
    qpI = 28
    qpMaxI = 36
    qpMinI = 10
    qpP = 28
    qpMaxP = 40
    qpMinP = 10
    qpOffsetB = 4
    qpMaxB = 44
    qpMinB = 10
    allowFrameSkip = 0
    removeExpensiveCoeff = 0
    chromaQPIndexOffset = 0
    IPQualityFactor = 0
    initialBufferLevel = 4000000
    HRDBufferSize = 4000000
    minPicSizeRatioI = 0
    maxPicSizeRatioI = 640
    minPicSizeRatioP = 0
    maxPicSizeRatioP = 0
    minPicSizeRatioB = 0
    maxPicSizeRatioB = 0
    enablePRC = 1
    enablePartialFrameSkip = 0
    discardSavedBits = 0
    reserved = 0
    VBRDuration = 8
    VBRsensitivity = 0
    skipDistributionWindowLength = 5
    numSkipInDistributionWindow = 1
    enableHRDComplianceMode = 1
    frameSkipThMulQ5 = 0
    vbvUseLevelThQ5 = 0
    reservedRC[0] = 0
    reservedRC[1] = 0
    reservedRC[2] = 0

  • Hello,

    I am not familiar with IPNC for dm8148 but per H.264 Encoder 2.0 on HDVICP2 for H264 codec version 2.0.02.02
    initialBufferLevel, HRDBufferSize shall be 2*targetBitRate for VBR Rate Control. 

    william calvert said:
    I tested with targetBitRate=500Kb and maxBitRate=1500Kb but the bitrate increases greater than 2500Kb when there is a lot of motion in the video.

    What is the resolution? If you are encoding high resolution with 500kb/s bitrate is normal to observe low quality.

    Best Regards,

    Margarita

  • Hi Margarita,

    I changed initialBufferLevel and HRDBufferSize to 1000000 but this didn't change the behaviour.

    The resolution is 1936x1936 - I set the target bitrate low (500Kb) to make it easier to see if the maxbitrate limit is applied but it doesn't seem to get applied. Would the low bit rate effect this?

    Thanks,

    William.

  • Hello William,

    william calvert said:
    The resolution is 1936x1936 - I set the target bitrate low (500Kb) to make it easier to see if the maxbitrate limit is applied but it doesn't seem to get applied.

    The bitrate is to low for this resolution that is why you are seeing low quality.

    Let me check  the settings.

    I will let you know.

    Best Regards,

    Margarita

  • Thanks Magarita,

    I'm not too concerned with quality for this test, I was just trying to confirm that CVBR rate control is running and the maxbitrate limit is applied.

    If I run at a higher target bitrate, eg. 3Mb and max bitrate 4.5Mb then its difficult to cause a bitrate greater than 4.5Mb, even with VBR configured.

    William.

  • Hi Margarita,

    Were you able to check the settings?

    Using encoder version 2.0.4, H264_Encoder_HDVICP2_UserGuide.pdf says to configure HF-VBR with settings:

    rateControlPreset = IVIDEO_USER_DEFINED (5)
    rcAlgo = IH264_RATECONTROL_PRC (0)
    maxBitRate >= (1.5 x targetBitRate )

    with these settings I can still create spikes in the bitrate much greater than maxBitRate (by covering and uncovering the camera lens). I am measuring the bitrate using wireshark with a 1 second interval.

    For the graph below the target bitrate was 2.6Mb and max bitrate was 4Mb - it shows spikes in bitrate up to 10Mb:

    Do you have any info on how the maxBitRate is applied?

    Thanks,

    William.

  • Hello,

    I have tried it on my side:

    Resolution: 1920x 1080

    Target bitrate : 3000kb/s

    What is the software release that you are using?

    What is the hardware platform? Is it EVM or it is custom board?

    What is the codec version?

    Keep in mind that it depends how complex are the scenes also.

    Best Regards,

    Margarita

  • Hi Margarita,

    Thanks for trying this - is there any difference in the graph if the max bit rate is not configured (VBR)?

    For my test purpose I am creating a very complex scene (by cover/uncover the camera lens) to test whether the max bit rate limit is applied. I am trying to configure maxBitRate to prevent any spikes in bandwidth but the problem is that the maxBitRate does not seem to get applied.

    For a test with a lot of motion in the video (eg. waving hand in front of camera) the bit rate does not increase above 1.5 x target rate even when VBR is configured so I can't use this to test CVBR.

    I am using custom hardware with DM8127, H264 codec version 2.0.4.1 (from IPNC RDK 3.5).

    Regards,

    William.

  • Hello,

    I notified the IPNC team to help here as well.

    Best Regards,

    Margarita