Adaptive bit rates (ABR) for video quality
HLS and DASH streams provide different bit rate encodings (profiles) for the same short burst of video. TVSDK can select the quality level for each burst based on the available bandwidth.
TVSDK constantly monitors the bit rate to ensure that the content is played at the optimal bit rate for the current network connection.
You can set the adaptive bit-rate (ABR) switching policy and the initial, minimum, and maximum bit rates for a multiple-bit-rate (MBR) stream. TVSDK automatically switches to the bit rate that provides the best playback experience in the specified configuration.
|Initial bit rate|
The desired playback bit rate (in bits per second) for the first segment. When playback starts, the closest profile, which is equal to or greater than the initial bit rate, is used for the first segment.
If a minimum bit rate is defined, and the initial bit rate is lower than the minimum rate, TVSDK selects the profile with the lowest bit rate above the minimum bit rate. If the initial rate is above the maximum rate, TVSDK selects the highest rate below the maximum rate.
If the initial bit rate is zero or undefined, the initial bit rate is determined by the ABR policy.
ABRInitialBitRate returns an integer value that represents the byte-per-second profile.
|Minimum bit rate|
The lowest allowed bit rate to which the ABR can switch. ABR switching ignores profiles with a bit rate that is lower than this bit rate.
ABRMinBitRate returns an integer value that represents the bits-per-second profile.
|Maximum bit rate|
The highest allowed bit rate to which the ABR can switch. ABR switching ignores profiles with a bit rate higher than this bit rate.
ABRMaxBitRate returns an integer value that represents the bits-per-second profile.
|ABR switching policy|| Playback switches gradually to the highest-bit-rate profile when possible. You can set the policy for ABR switching, which determines how quickly TVSDK switches between profiles. The default is
When TVSDK decides to switch to a higher bit rate, the player selects the ideal bit rate profile to switch to based on the current ABR policy:
If the initial bit rate is zero or is not specified, but a policy is specified, playback starts with the lowest bit rate profile for conservative, the profile closest to the median bit rate of available profiles for moderate, and the highest bit rate profile for aggressive.
The policy works in the constraints of the minimum and maximum bit rates, if these rates are specified.
ABRPolicy returns the current setting from the ABRControlParameters enum: CONSERVATIVE_POLICY, MODERATE_POLICY, or AGGRESSIVE_POLICY.
Keep the following information in mind:
- The TVSDK failover mechanism might override your settings, because TVSDK favors a continuous playback experience over strictly adhering to your control parameters.
- When the bit rate changes, TVSDK dispatches ProfileEvent.PROFILE_CHANGED .
- You can change your ABR settings at any time, and the player switches to use the profile that most closely matches the most recent settings.
For example, if a stream has the following profiles:
- 1: 300000
- 2: 700000
- 3: 1500000
- 4: 2400000
- 5: 4000000
If you specify a range of 300000 to 2000000, TVSDK considers only profiles 1, 2 and 3. This allows applications to adjust to various network conditions, such as switching from wi-fi to 3G or to various devices such as a phone, a tablet, or a desktop computer.
To set ABR control parameters, do one of the following:
- Use the ABRControlParameterBuilder helper class to set any subset of the parameters (operates on ABRControlParameter behind the scenes)
- Set the parameters on the ABRControlParameter class.
Configure adaptive bit rates using ABRControlParametersBuilder
Using the ABRControlParametersBuilder helper class is the simplest, most efficient way to set ABR parameters.
- The ABRControlParametersBuilder constructor sets all of the ABR parameters to default values on the underlying ABRControlParameters object.
- You can reset individual ABR parameters during run time, as long as you maintain a reference to the same ABRControlParametersBuilder instance.
This class also includes the toABRControlParameters() helper method. Use this method to get an instance of ABRControlParameters and set it on the mediaPlayer.ABRControlParameters property. This causes your settings to go into effect in the player.
- Instantiate the ABRControlParametersBuilder helper class, and set the parameters on the Media Player.For example, the following sample initializes all parameters to the defaults, then sets only the policy to conservative, and restricts the maximum bit rate to 1000000: >
var abrBuilder:ABRControlParametersBuilder = new ABRControlParametersBuilder(); abrBuilder.policy = ABRControlParameters.CONSERVATIVE_POLICY; abrBuilder.maxBitRate = 1000000; mediaPlayer.abrControlParameters = abrBuilder.toABRControlParameters(); ``` >
- Modify individual ABR parameters at run time.To modify individual parameters while leaving the rest of the parameters as they were:
// If later you want to reset the max bit rate to 2000000 abrBuilder.maxBitRate = 2000000; mediaPlayer.abrControlParameters = abrBuilder.toABRControlParameters();To retain your previous settings, you must maintain a reference to the same ABRControlParametersBuilder instance you created in Step 1.
Configure adaptive bit rates using ABRControlParameters
You can set ABR control values only with ABRControlParameters , but you can construct a new one at any time.
This ability to set ABR parameters was supported before the existence of the ABRControlParametersBuilder class, but this ability is still effective for setting ABR parameters at construction time. However, to change individual parameters after construction, you should use the ABRControlParametersBuilder class.
The following conditions apply to ABRControlParameters :
- You must provide values for all parameters at construction time.
- You cannot change individual values after construction time.
- If the parameters that you specify are outside of the allowed range, an ArgumentError is thrown.
- Decide on initial, minimum, and maximum bit rates.
- Determine the ABR policy:
- Set the ABR parameter values in the ABRControlParameters constructor and assign them to the Media Player.
mediaPlayer.abrControlParameters = new ABRControlParameters( ABRControlParameters.CONSERVATIVE_POLICY, 0, // Initial bit rate 0, // Minimum bit rate 1000000 // Maximum bit rate );