Setting the Maximum Bitrate for a Stream
You can dynamically control the maximum bitrate that a publisher can use for camera video streams.
This guide shows how to configure video bitrate settings, how to interact with different presets, how to set raw bitrates, and best practices for using the API effectively.
This topic includes the following sections:
Overview
You can dynamically set the maximum bitrate a publisher can use when encoding media. The video encoder then adjusts the bitrate dynamically, using a value within the allowed range, from a minimum threshold to the maximum bitrate set, based on network conditions and other constraints.
Setting the maximum bitrate can help to reduce bandwidth consumption when a user is connecting from a metered connection. Be sure to read the Limitations below.
Limitations
There are some important limitations to be aware of:
Network conditions — The actual bitrate achieved on the network may be lower than the value set, due to real-time network estimations, bandwidth fluctuations, and backend limitations.
Out-of-bounds values — If you provide a bitrate value outside the valid range, the SDK may ignore the request or return an error.
API usage
Video bitrate presets
The API offers video bitrate presets that simplify reducing video quality without needing to worry about codec and session settings. These presets are designed for common use cases like video conferencing and are tailored to 480p, 540p, 720p, and 1080p resolutions.
The available presets are:
DEFAULT— The default SDK bitrate setting that offers a balanced visual experience for video streams.BW_SAVER— A medium-quality setting for video conferencing that reduces the bitrate to save bandwidth.EXTRA_BW_SAVER— The lowest bitrate for essential video communication, offering low video quality but minimal bandwidth usage.
Please note that the exact bitrate values used when dealing with presets is implementation-specific, and depends on the negotiated codec and the media mode (relayed or routed). The Video API client SDKs include methods to set and get the bitrate preset.
Setting raw bitrate values
If the predefined bitrate presets do not meet your needs, you can set a custom raw bitrate value. This allows you to define specific bitrate limits within a range, from 5,000 bps to 10,000,000 bps. Please note that the value only applies to the encoder bitrate, so network overhead still applies on top of the chosen value.
The Vonage Video API client SDKs include methods to set the raw bitrate value and to retrieve it. Until a raw bitrate is set, or until only presets are set, the getter returns 0 (except for the JS SDK, in which the returned value is undefined). Once a raw bitrate is set, the bitrate preset getter returns 'custom', indicating that a custom value has been applied. However, do not use the preset 'custom' in the setter - just set the specific bitrate number to use as a maximum value.
Bitrate and encoding layer interaction with VP8 and scalability enabled
Changing the maximum bitrate when scalable VP8 is used triggers additional efficiency - the client SDK dynamically activates or deactivates the encoding layers based on the available bitrate to ensure the video stream is as efficient as possible. This process adapts the resolution at which the publisher is publishing.
The following notes apply to the preset when using VP8:
DEFAULT— This preset utilizes all available encoding layers. For a typical stream, this includes up to three layers (low, medium, and high).BW_SAVER— This preset only uses the first two encoding layers (low and medium quality). This is designed to save bandwidth, making it suitable for scenarios like video conferencing where high video quality might not be as critical.EXTRA_BW_SAVER— This preset further reduces the bitrate, using only the base (lowest) encoding layer. This is the most bandwidth-efficient mode, providing the bare minimum quality for meaningful video communication.
When you set a raw bitrate value, if the provided bitrate is insufficient to maintain certain encoding layers, the SDK automatically turns off the higher layers. For example, if the bitrate is too low for the medium or high-quality layers, those layers are discarded, and only the base layer is transmitted.
If a new provided bitrate is high enough to maintain more encoding layers, the SDK reactivates the higher encoding layers, progressively restoring the video quality by adding back the medium and high layers.
This mechanism ensures that the video stream remains as efficient as possible, maximizing the use of the available bandwidth without compromising the user experience.
Examples
At the start of a session, a publisher uses the DEFAULT preset, which provides full video quality. At this particular stage of the session, let's assume it negotiated the VP8 non-scalable codec. However, after a network change to a metered connection (for example, cellular), you may lower the publishing bandwidth using the BW_SAVER preset. When using a preset for the publisher's maximum bitrate, the client SDK makes sure that the quality level stays the same regardless of any event. When the network switches back to an unlimited connection, you can restore the default by setting the DEFAULT preset.
You can also set the raw bitrate value to set a bandwidth upper threshold.
For details for each client SDK, see the following:
The details on using Publisher Max Bitrate in the Vonage Video macOS client SDK are the same than the Linux client SDK.
Please note that the API is supported in recent versions of all supported browsers. If you encounter errors, make sure that the client is using an up-to-date browser version.
The Publisher object includes setVideoBitratePreset() and
getVideoBitratePreset() methods. The setVideoBitratePreset() method accepts
string values - 'DEFAULT', 'BW_SAVER', or 'EXTRA_BW_SAVER' (or their
lowercase counterparts) - and the getVideoBitratePreset() method returns these
values (or 'CUSTOM'). See Video bitrate presets for
more details on these presets.
Please note the getVideoBitratePreset()
method returns undefined if no preset or bitrate has previously been set.
The setVideoBitratePreset() method has one parameter: preset, the desired preset.
Example:
console.log(publisher.getVideoBitratePreset()); // undefined
await publisher.setVideoBitratePreset('BW_SAVER'); // or 'DEFAULT' or 'EXTRA_BW_SAVER'
console.log(publisher.getVideoBitratePreset()); // 'BW_SAVER'
The setVideoBitratePreset() method can throw an error with the name property of the error object set to the following:
OT_INVALID_PARAMETER- Invalid preset. It must be 'DEFAULT', 'BW_SAVER', or 'EXTRA_BW_SAVER'.OT_UNEXPECTED_ERROR_CODE- An unexpected error was encountered, and the preset was not updated.
Wrap the call to the setVideoBitratePreset() method in a try/catch block, even if the preset name is correct:
const invalidPreset = 'VERY_FAST';
try {
await publisher.setVideoBitratePreset(invalidPreset);
} catch (err) {
console.error(err.name);
// 'OT_INVALID_PARAMETER'
}
If the predefined presets are not suitable, you can manually set a custom raw bitrate value.
To get the maximum video bitrate currently set for a publisher, call the getMaxVideoBitrate() method of a Publisher object. This returns the currently set maximum bitrate (in bits per second). If no custom value is set, the function returns undefined.
Example:
console.log(publisher.getMaxVideoBitrate());
To set a custom maximum bitrate value (instead of a preset), use the setMaxVideoBitrate() method on of a Publisher object. This function has the a single parameter: bitrateBps, the desired maximum bitrate (in bits per second), between 5,000 and 10,000,000.
Example:
const new_bitrate = 300000; // 300 kbps
await publisher.setMaxVideoBitrate(new_bitrate);
The setMaxVideoBitrate() method can throw an error with the name property of the error object set to the following:
OT_INVALID_PARAMETER- Invalid bitrate. The value must be 0 or a number between 5000 and 10000000.OT_UNEXPECTED_ERROR_CODE- An unexpected error was encountered and the bitrate was not updated.
Wrap the call to the setVideoBitratePreset() method in a try/catch block, even if the number passed in is valid.
See Setting raw bitrate values for more details.
Setting the maximum bitrate value to 0 removes any previously set bitrate limitation, reverting to the default behavior.
const zero_bitrate = 0; // no limitations
const int new_bitrate = 300000; // 300 kbps
publisher.setMaxVideoBitrate(new_bitrate);
// publisher.getMaxVideoBitrate() === 300000
publisher.setMaxVideoBitrate(zero_bitrate);
// publisher.getMaxVideoBitrate() === 0
natale-p marked this conversation as resolved.
Calling the getVideoBitratePreset() method after setting a custom bitrate other than 0 returns CUSTOM.
const zero_bitrate = 0; // no limitations
const new_bitrate = 1000000; // 1 mbps
publisher.setMaxVideoBitrate(new_bitrate);
// publisher.getVideoBitratePreset() === 'CUSTOM'
publisher.setMaxVideoBitrate(zero_bitrate);
// publisher.getVideoBitratePreset() === 'DEFAULT'
The raw bitrate getter returns 0 when the publisher is using a preset.
let bitrateBps = publisher.getMaxVideoBitrate();
// bitrateBps === 0
publisher.setVideoBitratePreset('bw_saver);
bitrateBps = publisher.getMaxVideoBitrate();
// bitrateBps === 0
publisher.setVideoBitratePreset('extra_bw_saver');
bitrateBps = publisher.getMaxVideoBitrate();
// bitrateBps === 0
publisher.setMaxVideoBitrate(200000);
bitrateBps = publisher.getMaxVideoBitrate();
// bitrateBps === 200000
publisher.setVideoBitratePreset('default');
bitrateBps = publisher.getMaxVideoBitrate();
// bitrateBps === 0
The PublisherKit .VideoBitratePreset enum includes preset values:
VideoBitratePresetDefaultVideoBitratePresetBwSaverVideoBitratePresetExtraBwSaverVideoBitratePresetCustom
See Video bitrate presets for details on these presets.
To retrieve the currently configured video bitrate preset for a given publisher, call the PublisherKit.getVideoBitratePreset() method:
PublisherKit.VideoBitratePreset retrievedBitratePreset = publisherKit.getVideoBitratePreset();
System.out.println("The video bitrate preset is: " + retrievedBitratePreset);
To set a preset, call the PublisherKit.setVideoBitratePreset() method. This method includes one parameter: preset — a value from the VideoBitratePreset enum. Do not use VideoBitratePresetCustom.
Example:
PublisherKit.VideoBitratePreset bitratePreset = PublisherKit.VideoBitratePreset.VideoBitratePresetBwSaver;
publisherKit.setVideoBitratePreset(bitratePreset);
If the predefined presets are not suitable, you can manually set a custom raw bitrate value.
To get the maximum video bitrate currently set for a publisher, call the PublisherKit.getMaxVideoBitrate() method. This returns the currently set maximum bitrate (in bits per second). If no custom value is set, the method returns 0.
Example:
int retrievedMaxVideoBitrate = publisherKit.getMaxVideoBitrate();
System.out.println("The maximum video bitrate is: " + retrievedMaxVideoBitrate + " kbps");
To set a custom maximum bitrate value (instead of a preset), use the PublisherKit.setMaxVideoBitrate() method. This method has one parameter: maxVideoBitrate, the desired maximum bitrate (in bits per second). The maxVideoBitrate value must be between 5,000 and 10,000,000.
Example:
int maxVideoBitrate = 300000; // 300 kbps
publisherKit.setMaxVideoBitrate(maxVideoBitrate);
See Setting raw bitrate values for more details.
Setting the raw bitrate value to 0 removes any previously set bitrate limitation, reverting to the default behavior.
int zeroBitrate = 0; // No limitations
int newBitrate = 300000; // 300 kbps
// Set the maximum video bitrate
publisherKit.setMaxVideoBitrate(newBitrate);
// Validate that the bitrate was set correctly
if (publisherKit.getMaxVideoBitrate() == newBitrate) {
System.out.println("Max video bitrate set successfully to: " + newBitrate);
}
// Reset the maximum video bitrate to the default behavior
publisherKit.setMaxVideoBitrate(zeroBitrate);
// Validate that the bitrate was reset to default
if (publisherKit.getMaxVideoBitrate() == zeroBitrate) {
System.out.println("Max video bitrate reset to default.");
}
Calling the getVideoBitratePreset() method after setting a custom bitrate returns VideoBitratePresetCustom.
int newBitrate = 1000000; // 1 Mbps
// Set a custom bitrate
publisherKit.setMaxVideoBitrate(newBitrate);
// Validate that the preset is set to CUSTOM
if (publisherKit.getVideoBitratePreset() == PublisherKit.VideoBitratePreset.VideoBitratePresetCustom) {
System.out.println("Video bitrate preset set to CUSTOM.");
}
// Reset bitrate to default
publisherKit.setMaxVideoBitrate(zeroBitrate);
// Validate that the preset is reset to DEFAULT
if (publisherKit.getVideoBitratePreset() == PublisherKit.VideoBitratePreset.VideoBitratePresetDefault) {
System.out.println("Video bitrate preset reset to DEFAULT.");
}
The PublisherKit.getMaxVideoBitrate() method returns 0 when the publisher is using a preset.
// Get the current raw bitrate (default should be 0)
int bitrateBps = publisherKit.getMaxVideoBitrate();
assert bitrateBps == 0;
// Set the preset to BW_SAVER
publisherKit.setVideoBitratePreset(PublisherKit.VideoBitratePreset.VideoBitratePresetBwSaver);
bitrateBps = publisherKit.getMaxVideoBitrate();
assert bitrateBps == 0;
// Set the preset to EXTRA_BW_SAVER
publisherKit.setVideoBitratePreset(PublisherKit.VideoBitratePreset.VideoBitratePresetExtraBwSaver);
bitrateBps = publisherKit.getMaxVideoBitrate();
assert bitrateBps == 0;
// Set a custom bitrate
publisherKit.setMaxVideoBitrate(200000);
bitrateBps = publisherKit.getMaxVideoBitrate();
assert bitrateBps == 200000;
// Reset the preset to DEFAULT
publisherKit.setVideoBitratePreset(PublisherKit.VideoBitratePreset.VideoBitratePresetDefault);
bitrateBps = publisherKit.getMaxVideoBitrate();
assert bitrateBps == 0;
The OTVideoBitratePreset enum includes preset values:
OTVideoBitratePresetDefaultOTVideoBitratePresetBwSaverOTVideoBitratePresetExtraBwSaverOTVideoBitratePresetCustom
See Video bitrate presets for details on these presets.
To retrieve the currently configured video bitrate preset for a given publisher, set the OTPublisherKit.videoBitratePreset property:
OTVideoBitratePreset retrievedBitratePreset = publisher.videoBitratePreset;
NSLog(@"The video bitrate preset is: %ld", (long)retrievedBitratePreset);
To set a preset, assign a value to the videoBitratePreset property. This property accepts one of the values from the OTVideoBitratePreset
enum, except for OTVideoBitratePresetCustom.
Example:
publisher.videoBitratePreset = OTVideoBitratePresetBwSaver;
If the predefined presets are not suitable, you can manually set a custom raw bitrate value.
To get the maximum video bitrate currently set for a publisher, check the OTPublisherKit.maxVideoBitrate property. This is set to the maximum bitrate (in bits per second). If no custom value is set, the property is set to 0.
Example:
int retrievedMaxVideoBitrate = publisher.maxVideoBitrate;
NSLog(@"The maximum video bitrate is: %d kbps", retrievedMaxVideoBitrate);
To use a custom maximum bitrate value (instead of a preset), set the OTPublisherKit.maxVideoBitrate property. This property accepts values between 5,000 and 10,000,000 (in bits per second).
Example:
publisher.maxVideoBitrate = 300000; // 300 kbps
See Setting raw bitrate values for more details.
Setting the raw bitrate value to 0 removes any previously set bitrate limitation, reverting to the default behavior.
publisher.maxVideoBitrate = 300000; // Set the maximum video bitrate to 300 kbps
NSLog(@"Max video bitrate set successfully to: %d", publisher.maxVideoBitrate);
publisher.maxVideoBitrate = 0; // Reset the maximum video bitrate to the default behavior
NSLog(@"Max video bitrate reset to default: %d", publisher.maxVideoBitrate);
After setting a custom bitrate, the videoBitratePreset property is set to OTVideoBitratePresetCustom.
publisher.maxVideoBitrate = 1000000; // Set a custom bitrate to 1 Mbps
if (publisher.videoBitratePreset == OTVideoBitratePresetCustom) {
NSLog(@"Video bitrate preset set to CUSTOM.");
}
publisher.maxVideoBitrate = 0; // Reset bitrate to default
if (publisher.videoBitratePreset == OTVideoBitratePresetDefault) {
NSLog(@"Video bitrate preset reset to DEFAULT.");
}
The publisher.maxVideoBitrate property is set to 0 when the publisher is using a preset.
NSLog(@"Default bitrate: %d", publisher.maxVideoBitrate); // Default should be 0
publisher.videoBitratePreset = OTVideoBitratePresetBwSaver;
NSLog(@"Bitrate for BW_SAVER preset: %d", publisher.maxVideoBitrate); // Should be 0
publisher.videoBitratePreset = OTVideoBitratePresetExtraBwSaver;
NSLog(@"Bitrate for EXTRA_BW_SAVER preset: %d", publisher.maxVideoBitrate); // Should be 0
publisher.maxVideoBitrate = 200000; // Set a custom bitrate
NSLog(@"Custom bitrate: %d", publisher.maxVideoBitrate);
publisher.videoBitratePreset = OTVideoBitratePresetDefault; // Reset to default preset
NSLog(@"Bitrate after reset to DEFAULT preset: %d", publisher.maxVideoBitrate); // Should be 0
The VideoBitratePreset enum includes preset values:
DefaultBwSaverExtraBwSaverCustom
See Video bitrate presets for details on these presets.
To retrieve the currently configured video bitrate preset for a given publisher, access the Publisher.VideoBitratePreset property:
var preset = publisher.VideoBitratePreset;
if (preset == VideoBitratePreset.BwSaver)
{
Console.WriteLine("The publisher is using the BW_SAVER preset.");
}
To set a preset, set the Publisher.VideoBitratePreset property to a value from theVideoBitratePreset enum. Do not use the Custom value.
Example:
publisher.VideoBitratePreset = VideoBitratePreset.BwSaver;
Console.WriteLine("Bitrate preset successfully set to BW_SAVER.");
If the predefined presets are not suitable, you can manually set a custom raw bitrate value.
To get the current maximum video bitrate (in bits per second), access the Publisher.MaxVideoBitrate property. If no custom value is set, it is set to 0.
Example:
int maxBitrate = publisher.MaxVideoBitrate;
Console.WriteLine($"Current max video bitrate: {maxBitrate} bps");
To set a custom maximum bitrate (instead of a preset), assign a value (between 5,000 and 10,000,000) to the MaxVideoBitrate property.
Example:
int newBitrate = 300000; // 300 kbps
publisher.MaxVideoBitrate = newBitrate;
Console.WriteLine($"Successfully set max video bitrate to {newBitrate} bps.");
See Setting raw bitrate values for more details.
Setting the raw bitrate value to 0 removes any previously set bitrate limitation, reverting to the default behavior.
int zeroBitrate = 0; // no limitations
int newBitrate = 300000;
publisher.MaxVideoBitrate = newBitrate;
System.Diagnostics.Debug.Assert(publisher.MaxVideoBitrate == newBitrate);
publisher.MaxVideoBitrate = zeroBitrate;
System.Diagnostics.Debug.Assert(publisher.MaxVideoBitrate == zeroBitrate);
Setting a custom bitrate causes the VideoBitratePreset property to be set to VideoBitratePreset.Custom:
publisher.MaxVideoBitrate = 1000000; // 1 Mbps
System.Diagnostics.Debug.Assert(publisher.VideoBitratePreset == VideoBitratePreset.Custom);
publisher.MaxVideoBitrate = 0;
System.Diagnostics.Debug.Assert(publisher.VideoBitratePreset == VideoBitratePreset.Default);
The MaxVideoBitrate property returns 0 when the publisher is using a preset:
publisher.VideoBitratePreset = VideoBitratePreset.BwSaver;
System.Diagnostics.Debug.Assert(publisher.MaxVideoBitrate == 0);
publisher.VideoBitratePreset = VideoBitratePreset.ExtraBwSaver;
System.Diagnostics.Debug.Assert(publisher.MaxVideoBitrate == 0);
publisher.MaxVideoBitrate = 200000;
System.Diagnostics.Debug.Assert(publisher.MaxVideoBitrate == 200000);
publisher.VideoBitratePreset = VideoBitratePreset.Default;
System.Diagnostics.Debug.Assert(publisher.MaxVideoBitrate == 0);
The otc_video_bitrate_preset enum, in the publisher.h header, includes preset values:
OTC_VIDEO_BITRATE_PRESET_DEFAULTOTC_VIDEO_BITRATE_PRESET_BW_SAVEROTC_VIDEO_BITRATE_PRESET_EXTRA_BW_SAVEROTC_VIDEO_BITRATE_PRESET_CUSTOM
See Video bitrate presets for details on these presets.
To retrieve the currently configured video bitrate preset for a given publisher, call the otc_publisher_get_video_bitrate_preset() function:
enum otc_video_bitrate_preset preset = otc_publisher_get_video_bitrate_preset(publisher);
if (preset == OTC_VIDEO_BITRATE_PRESET_BW_SAVER) {
printf("The publisher is using the BW_SAVER preset.\n");
}
To set a preset, call the otc_publisher_set_video_bitrate_preset() function. This function includes two parameters:
publisher— A pointer to the otc_publisher instance.preset— A value fromotc_video_bitrate_preset. Do not useOTC_VIDEO_BITRATE_PRESET_CUSTOM.
The function returns one of these values:
OTC_SUCCESS— The preset was successfully applied.OTC_ERROR_INVALID_PARAMETER— The provided publisher is NULL or the preset is invalid.
Example:
otc_status status = otc_publisher_set_video_bitrate_preset(publisher, OTC_VIDEO_BITRATE_PRESET_BW_SAVER);
if (status == OTC_SUCCESS) {
printf("Bitrate preset successfully set to BW_SAVER.\n");
} else {
printf("Failed to set bitrate preset.\n");
}
If the predefined presets are not suitable, you can manually set a custom raw bitrate value.
To get the maximum video bitrate currently set for a publisher, call the otc_publisher_get_max_video_bitrate() function. This returns the currently set maximum bitrate (in bits per second). If no custom value is set, the function returns 0.
Example:
int max_bitrate = otc_publisher_get_max_video_bitrate(publisher);
printf("Current max video bitrate: %d bps\n", max_bitrate);
To set a custom maximum bitrate value (instead of a preset), use the otc_publisher_set_max_video_bitrate() function. This function has the following parameters:
publisher— A pointer to an existing otc_publisher instance.bitrate_bps— The desired maximum bitrate (in bits per second). Must be between 5,000 and 10,000,000. The function returns one of the following values:OTC_SUCCESS— The bitrate was successfully applied.OTC_ERROR_INVALID_PARAMETER— The publisher pointer isNULL, orbitrate_bpsis out of range. Example:
int new_bitrate = 300000; // 300 kbps
otc_status status = otc_publisher_set_max_video_bitrate(publisher, new_bitrate);
if (status == OTC_SUCCESS) {
printf("Successfully set max video bitrate to %d bps.\n", new_bitrate);
} else {
printf("Failed to set max video bitrate.\n");
}
See Setting raw bitrate values for more details.
Setting the raw bitrate value to 0 removes any previously set bitrate limitation, reverting to the default behavior.
const int zero_bitrate = 0; // no limitations
const int new_bitrate = 300000; // 300 kbps
otc_status status = otc_publisher_set_max_video_bitrate(publisher, new_bitrate);
if (status == OTC_SUCCESS) {
assert(otc_publisher_get_max_video_bitrate(publisher) == new_bitrate);
}
status = otc_publisher_set_max_video_bitrate(publisher, zero_bitrate);
if (status == OTC_SUCCESS) {
assert(otc_publisher_get_max_video_bitrate(publisher) == zero_bitrate);
}
Calling the (otc_publisher_get_video_bitrate_preset()) function after setting a custom bitrate returns OTC_VIDEO_BITRATE_PRESET_CUSTOM.
const int new_bitrate = 1000000; // 1 mbps
otc_status status = otc_publisher_set_max_video_bitrate(publisher, new_bitrate);
if (status == OTC_SUCCESS) {
assert(otc_publisher_get_video_bitrate_preset(publisher) == OTC_VIDEO_BITRATE_PRESET_CUSTOM);
}
status = otc_publisher_set_max_video_bitrate(publisher, zero_bitrate);
if (status == OTC_SUCCESS) {
assert(otc_publisher_get_video_bitrate_preset(publisher) == OTC_VIDEO_BITRATE_PRESET_DEFAULT);
}
The raw bitrate getter returns 0 when the publisher is using a preset.
// Assume all the statuses are OTC_SUCCESS
int bitrate_bps = otc_publisher_get_max_video_bitrate(publisher);
assert(bitrate_bps == 0);
otc_publisher_set_video_bitrate_preset(publisher, OTC_VIDEO_BITRATE_PRESET_BW_SAVER);
bitrate_bps = otc_publisher_get_max_video_bitrate(publisher);
assert(bitrate_bps == 0);
otc_publisher_set_video_bitrate_preset(publisher, OTC_VIDEO_BITRATE_PRESET_EXTRA_BW_SAVER);
bitrate_bps = otc_publisher_get_max_video_bitrate(publisher);
assert(bitrate_bps == 0);
otc_publisher_set_max_video_bitrate(publisher, 200000);
bitrate_bps = otc_publisher_get_max_video_bitrate(publisher);
assert(bitrate_bps == 200000);
otc_publisher_set_video_bitrate_preset(publisher, OTC_VIDEO_BITRATE_PRESET_DEFAULT);
bitrate_bps = otc_publisher_get_max_video_bitrate(publisher);
assert(bitrate_bps == 0);
Best practices
To ensure the best performance and optimal bandwidth usage, follow these best practices:
Use predefined bitrate presets — When possible, use the predefined bitrate presets (
DEFAULT,BW_SAVER,EXTRA_BW_SAVER) to manage video quality. These presets are tailored for common scenarios like video conferencing, ensuring that video quality is balanced with bandwidth efficiency. More importantly, they abstract codec details and media modes.Be cautious with custom bitrate settings — While custom bitrate settings give you more control, their usage is tied to codec details that may change during the WebRTC negotiation phase. We recomment to use them sparingly, and only when an hard threshold on the bitrate is needed.
Don't apply custom bitrates or presets to screen-sharing streams — Screen-sharing stream encoding differs from camera stream encoding. Using the maximum bitrate API to limit a screen-sharing stream may degrade the quality without offering any bandwidth improvement.