ABR logic for dash.js


reference:


dash.js ABR rule process

  • Main rules : Use the DANYMIC algorithm to dynamically switch between ThroughputRule and BolaRule . The switching rules are:
    • Startup: Use ThroughputRule
    • When the buffer exceeds 10s: If the code rate selected by BolaRule is not lower than ThroughputRule , switch to BolaRule
    • When the buffer is lower than 10s: If the code rate selected by BolaRule is lower than ThroughputRule , switch to ThroughputRule
  • Secondary rules : Use the secondary rules to select the bit rate, compare it with the bit rate selected by the main rules, and take the smaller value
    • InsufficientBufferRule
    • SwitchHistoryRule
    • DroppedFramesRule

*Note: In dash.js, ABR logic audio and video are common; if you need to implement a custom ABR algorithm in dash.js, please refer to: How to add custom ABR rules in dash.js?


1. Main rules

  • ThroughputRule
    • Estimate the future throughput using the sliding window average , and choose the maximum bit rate video that is not higher than the estimated value
      • The window size is 4~20 (the more severe the throughput jitter, the larger the window), and the averaged throughput × 0.9 is used as an estimated value
    • If the highest bit rate is selected and the buffer level is higher than the rich buffer threshold, a lower bit rate will not be selected until the buffer level drops to the threshold (even if the throughput drops)
      • This threshold is 【MediaPlayer】setRichBufferThreshold(value)set by
  • BolaRule (for its core principles, please refer to: BOLA (INFOCOM '16) core algorithm logic , for code logic, please refer to: BOLA dash.js code implementation )
    • Using BOLA-E, the bit rate is selected based on the buffer , and the problem of BOLA continuously downloading low bit rate video blocks during startup or seek is improved by introducing the Placeholder algorithm
      • Placeholder Algorithm
        • Starting point: Sometimes (such as startup or seek) buffer cannot reflect throughput information
        • Principle: Insert placeholder segments (placeholder segments, which cannot be played) into the buffer to increase the buffer level, so that the buffer-based method has enough buffer information to make a bit rate decision
        • step:
          • estimated throughput
          • Choose the appropriate code rate based on the estimated throughput
          • Calculation allows BOLA to make rate decision buffer level
          • Insert enough placeholder segments into the buffer to reach the target buffer level. The required number of placeholder segments is equal to the target buffer level minus the actual number of segments in the buffer
      • BOLA will not choose high bitrate when throughput estimate is not enough to support high bitrate download
      • Record the reasons for the buffer level drop, and keep a higher bit rate selection when the buffer drops due to non-bandwidth reasons

2. Minor rules

  • InsufficientBufferRule
    • Purpose: To avoid the possible lag caused by the Palceholder algorithm of BOLA-E
    • Rules: When the buffer is low, use a conservative throughput estimate to select the bit rate; when a freeze occurs, force the selection of the lowest bit rate to recover quickly
    • step:
      • Estimate the current throughput by 50% to get safe throughput
      • Calculate safe throughput×buffer level (excluding placeholder) to get safe download size
      • Download blocks whose size does not exceed the safe download size (that is, the code rate that does not exceed the safe download size / fragmentDuration)
  • SwitchHistoryRule
    • Purpose: To avoid bit rate jitter (frequent switching)
    • Rule: If all other ABR rules start to reduce the bit rate selection from a certain bit rate, the bit rate and higher bit rates are disabled within 8 segments
  • DroppedFramesRule
    • Purpose: Avoid bitrates that cannot be rendered correctly due to CPU limitations
    • Rule: When the frame drop exceeds 15% at a certain bit rate, disable this bit rate and higher bit rates

3. Progress monitoring rules

  • AbandonRequestRule
    • Rule: If there is a risk of freezing during the block download process, cancel the download of the current block and download a block with a lower bit rate to avoid freezing

4. Custom rules

  • Add custom rules to the ABR rule collection:【MediaPlayer】addABRCustomRule(type, rulename, rule)
  • Use a custom rule, disabling other built-in rules:【MediaPlayer】useDefaultABRRules(value)

Code call process

  • 【ABRRulesCollection】getMaxQuality()
    • DYNAMIC
      • 【ThroughputRule】getMaxIndex()
      • 【BolaRule】getMaxIndex()
    • 【InsufficientBufferRule】getMaxIndex()
    • 【SwitchHistoryRule】getMaxIndex()
    • 【DroppedFramesRule】getMaxIndex()

See the following two pictures for details:
insert image description here
insert image description here

Guess you like

Origin blog.csdn.net/LvGreat/article/details/103735968