Skip to content

Commit

Permalink
Add ThroughputRule and put throughput related settings to its own mar…
Browse files Browse the repository at this point in the history
…kdown file
  • Loading branch information
dsilhavy committed Jan 25, 2024
1 parent 950ccb5 commit b2f58d7
Show file tree
Hide file tree
Showing 6 changed files with 86 additions and 58 deletions.
11 changes: 5 additions & 6 deletions pages/advanced/abr/abandon-request-rule.md
Expand Up @@ -3,7 +3,6 @@ layout: default
title: AbandonRequestRule
parent: Adaptive Bitrate Streaming
grand_parent: Advanced Features
nav_order: 2
---

# AbandonRequestRule
Expand Down Expand Up @@ -47,11 +46,11 @@ if (remainingBytesToDownload > totalBytesForOptimalRepresentation) {

## Configuration Options

| ABR Rule | Description |
|:-------------------------|:------------------------------------------------------------------------------------------------------------------------------------------------------|
| `abandonDurationMultiplier` | Factor to multiply with the segment duration to compare against the estimated remaining download time of the current segment. See code example above. |
| `minSegmentDownloadTimeThresholdInMs` | The `AbandonRequestRule` only kicks if the download time of the current segment exceeds this value. |
| `minThroughputSamplesThreshold` | Minimum throughput samples (equivalent to number of `progress` events) required before the `AbandonRequestRule` kicks in. |
| Parameter | Description |
|:--------------------------------------|:------------------------------------------------------------------------------------------------------------------------------------------------------|
| `abandonDurationMultiplier` | Factor to multiply with the segment duration to compare against the estimated remaining download time of the current segment. See code example above. |
| `minSegmentDownloadTimeThresholdInMs` | The `AbandonRequestRule` only kicks if the download time of the current segment exceeds this value. |
| `minThroughputSamplesThreshold` | Minimum throughput samples (equivalent to number of `progress` events) required before the `AbandonRequestRule` kicks in. |



3 changes: 1 addition & 2 deletions pages/advanced/abr/l2a.md
@@ -1,9 +1,8 @@
---
layout: default
title: L2A
title: L2A Rule
parent: Adaptive Bitrate Streaming
grand_parent: Advanced Features
nav_order: 2
---

# L2A
Expand Down
3 changes: 1 addition & 2 deletions pages/advanced/abr/lol_plus.md
@@ -1,9 +1,8 @@
---
layout: default
title: LoL+
title: LoL+ Rule
parent: Adaptive Bitrate Streaming
grand_parent: Advanced Features
nav_order: 2
---

# LoL+
Expand Down
52 changes: 4 additions & 48 deletions pages/advanced/abr/settings.md
Expand Up @@ -3,7 +3,6 @@ layout: default
title: ABR Settings
parent: Adaptive Bitrate Streaming
grand_parent: Advanced Features
nav_order: 1
---

<details open markdown="block">
Expand Down Expand Up @@ -45,10 +44,10 @@ player.updateSettings({
});
```

| ABR Rule | Description |
|:-----------------|:------------|
| `throughputRule` | tbd |
| `bolaRule` | tbd |
| ABR Rule | Description |
|:-----------------|:---------------------------------------|
| `throughputRule` | [ThroughputRule](throughput-rule.html) |
| `bolaRule` | tbd |

**Important**: If both `throughputRule` and `bolaRule` are enabled dash.js dynamically switches between those two
rules based on the current buffer level.
Expand Down Expand Up @@ -221,46 +220,3 @@ player.updateSettings({
```

A detailed example is available [here](https://reference.dashif.org/dash.js/nightly/samples/abr/fastswitch.html).

## Throughput calculation modes

dash.js provides multiple options to configure the calculation of the current average throughput. This calculation is an
important input for most of the ABR rules e.g. the `ThroughputRule`.
The following options are available:

| Throughput Calculation Mode | Description |
|:-------------------------------------|:------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `EWMA` | Exponential Weighted Moving Average (EWMA) is a calculation mode that assigns exponentially decreasing weights to the historical data points. It gives more importance to recent data while gradually decreasing the influence of older data points. The `settings.abr.throughput.ewma` object allows the configuration of the EWMA parameters. |
| `ZLEMA` | Zero-Lag Exponential Moving Average (ZLEMA) is a calculation mode that aims to reduce or eliminate the lag typically associated with traditional exponential moving averages. It achieves this by using a specific formula that adjusts the weights of the data points to minimize lag |
| `ARITHMETIC_MEAN` | Arithmetic mean, also known as the average, is a statistical measure that calculates the sum of a set of values divided by the number of values in the set. |
| `BYTE_SIZE_WEIGHTED_ARITHMETIC_MEAN` | Byte size weighted arithmetic mean is a calculation method that assigns weights to different values based on their respective byte sizes. To calculate the byte size weighted arithmetic mean, you multiply each value by its corresponding byte size, then sum up the weighted values, and divide the sum by the total byte size. |
| `DATE_WEIGHTED_ARITHMETIC_MEAN` | Date-weighted arithmetic mean is a calculation method that assigns weights to different values based on their respective dates. To calculate the date-weighted arithmetic mean, you multiply each value by its corresponding weight based on the date, then sum up the weighted values, and divide the sum by the total weight. |
| `HARMONIC_MEAN` | To calculate the harmonic mean, you take the total number of values in the set, divide it by the sum of the reciprocals of each value, and then take the reciprocal of that result. As the harmonic mean involves taking the reciprocals of the values, extremely large values have a significant impact on the calculation. |
| `BYTE_SIZE_WEIGHTED_HARMONIC_MEAN` | Similar to the harmonic mean calculation but assigns weights to the different sample values based on their respective byte sizes. |
| `DATE_WEIGHTED_HARMONIC_MEAN` | Similar to the harmonic mean calculation but assigns weights to the different sample values based on their respective dates. The most recent sample has a higher weight than the previous samples. |

The default mode is `EWMA`. Most of the throughput calculation modes work on a fixed number of throughput samples.
The `settings.abr.throughput.sampleSettings` objects allows the configuration of sample related settings.

In the example below we change the default mode to byte size weighted harmonic mean. In addition, we change the number
of samples to be used to five and disable the automatic adjustment of the sample
size.

A detailed example is
available [here](https://reference.dashif.org/dash.js/nightly/samples/abr/average-calculation-mode.html).

```js
player.updateSettings({
streaming: {
abr: {
throughput: {
averageCalculationMode: dashjs.Constants.THROUGHPUT_CALCULATION_MODES.BYTE_SIZE_WEIGHTED_HARMONIC_MEAN,
sampleSettings: {
vod: 5,
enableSampleSizeAdjustment: false
}
},
}
}
});
```
49 changes: 49 additions & 0 deletions pages/advanced/abr/throughput-calculation.md
@@ -0,0 +1,49 @@
---
layout: default
title: Throughput Calculation
parent: Adaptive Bitrate Streaming
grand_parent: Advanced Features
---

# Throughput Calculation

dash.js provides multiple options to configure the calculation of the current average throughput. This calculation is an
important input for most of the ABR rules e.g. the [ThroughputRule](throughput-rule.html).
The following options are available:

| Throughput Calculation Mode | Description |
|:-------------------------------------|:------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `EWMA` | Exponential Weighted Moving Average (EWMA) is a calculation mode that assigns exponentially decreasing weights to the historical data points. It gives more importance to recent data while gradually decreasing the influence of older data points. The `settings.abr.throughput.ewma` object allows the configuration of the EWMA parameters. |
| `ZLEMA` | Zero-Lag Exponential Moving Average (ZLEMA) is a calculation mode that aims to reduce or eliminate the lag typically associated with traditional exponential moving averages. It achieves this by using a specific formula that adjusts the weights of the data points to minimize lag |
| `ARITHMETIC_MEAN` | Arithmetic mean, also known as the average, is a statistical measure that calculates the sum of a set of values divided by the number of values in the set. |
| `BYTE_SIZE_WEIGHTED_ARITHMETIC_MEAN` | Byte size weighted arithmetic mean is a calculation method that assigns weights to different values based on their respective byte sizes. To calculate the byte size weighted arithmetic mean, you multiply each value by its corresponding byte size, then sum up the weighted values, and divide the sum by the total byte size. |
| `DATE_WEIGHTED_ARITHMETIC_MEAN` | Date-weighted arithmetic mean is a calculation method that assigns weights to different values based on their respective dates. To calculate the date-weighted arithmetic mean, you multiply each value by its corresponding weight based on the date, then sum up the weighted values, and divide the sum by the total weight. |
| `HARMONIC_MEAN` | To calculate the harmonic mean, you take the total number of values in the set, divide it by the sum of the reciprocals of each value, and then take the reciprocal of that result. As the harmonic mean involves taking the reciprocals of the values, extremely large values have a significant impact on the calculation. |
| `BYTE_SIZE_WEIGHTED_HARMONIC_MEAN` | Similar to the harmonic mean calculation but assigns weights to the different sample values based on their respective byte sizes. |
| `DATE_WEIGHTED_HARMONIC_MEAN` | Similar to the harmonic mean calculation but assigns weights to the different sample values based on their respective dates. The most recent sample has a higher weight than the previous samples. |

The default mode is `EWMA`. Most of the throughput calculation modes work on a fixed number of throughput samples.
The `settings.abr.throughput.sampleSettings` objects allows the configuration of sample related settings.

In the example below we change the default mode to byte size weighted harmonic mean. In addition, we change the number
of samples to be used to five and disable the automatic adjustment of the sample
size.

A detailed example is
available [here](https://reference.dashif.org/dash.js/nightly/samples/abr/average-calculation-mode.html).

```js
player.updateSettings({
streaming: {
abr: {
throughput: {
averageCalculationMode: dashjs.Constants.THROUGHPUT_CALCULATION_MODES.BYTE_SIZE_WEIGHTED_HARMONIC_MEAN,
sampleSettings: {
vod: 5,
enableSampleSizeAdjustment: false
}
},
}
}
});
```
26 changes: 26 additions & 0 deletions pages/advanced/abr/throughput-rule.md
@@ -0,0 +1,26 @@
---
layout: default
title: ThroughputRule
parent: Adaptive Bitrate Streaming
grand_parent: Advanced Features
---

# ThroughputRule

## Description

The `ThroughputRule` is a very simple ABR rule that uses the average throughput of the previous media segment downloads
to derive the optimal bitrate for the next media segment request.

The essential lines in the implementation are depicted below:

```js
const throughput = throughputController.getSafeAverageThroughput(mediaType);
switchRequest.representation = abrController.getOptimalRepresentationForBitrate(mediaInfo, throughput, true);
```

## Configuration Options

There are no values that are specifically targeting the rule. However, there are some throughput related parameters that
implicitly influence this rule as it is using `throughputController.getSafeAverageThroughput()`. The throughput related
parameters are documented [here](throughput-calculation.html).

0 comments on commit b2f58d7

Please sign in to comment.