WebRTC streamer¶
Usually you wouldn’t need to adjust the default WebRTC streamer configuration because it is optimised to provide a good balance between low latency and high quality. However, you can still fine-tune it to provide better results in certain situations.
Place the WebRTC streamer configuration at /var/lib/anbox/streamer.json
within the instance before the Anbox runtime starts. The configuration can be shipped as part of an application or an addon.
The configuration file uses the JSON format. It has the following structure:
Name |
Value type |
Default |
Description |
---|---|---|---|
|
array of objects |
|
Bitrate limits to apply to the video encoder. |
|
bool |
|
If set to true, multi-pass encoding is enabled. |
|
bool |
|
If set to true, multi-pass encoding will be run only for a quarter of a frame’s resolution. |
|
bool |
|
If set to true, adaptive quantisation is enabled. |
|
integer |
|
Strength of adaptive quantisation: a value from |
|
integer |
|
Preset to use (a value from |
See the NVENC Video Encoder API documentation for more details on the nvidia_h264
options.
Video bitrate limits¶
Bitrate limits allow to fine-tune which minimum and maximum bitrate the WebRTC streamer will use to dynamically decide the target bitrate for the encoded video stream. As network conditions are constantly changing, WebRTC automatically tries to adapt the video bitrate to find a configuration with best throughput, quality and latency. The bitrate limits allow changing the default values that WebRTC will use as the lower and upper bound for its decision.
As different resolutions require different bitrates, the bitrate limits allow defining a minimum and maximum bitrate for frames having up to the specified number of pixels. This puts aside the actual geometry of the frame and solely concentrates on the amount of pixels the frame has.
The WebRTC streamer will pick the closest limit for the configured resolution by comparing the number of pixels and frame rate. The following rules apply:
If more than one limit is specified, the WebRTC streamer selects the nearest limit with a number of pixels higher than the number of pixels that a frame of the given resolution has.
If multiple limits have the same number of pixels, the streamer will sort limits descending by frame rate and apply the nearest.
The JSON object defining a bitrate limit has the following possible fields:
Name |
Value type |
Default |
Description |
---|---|---|---|
|
integer |
|
Number of pixels up to which the limit is considered. |
|
integer |
|
Frame rate the limit applies for. |
|
integer |
|
Minimum bitrate in kb/s. |
|
integer |
|
Maximum bitrate in kb/s. |
If no limits are specified, the default limits from the following table will be used:
Resolution |
Number of pixels |
Frame rate |
Minimum bitrate |
Maximum bitrate |
---|---|---|---|---|
720p |
|
|
1000 kb/s |
3000 kb/s |
720p |
|
|
2500 kb/s |
5000 kb/s |
1080p |
|
|
3000 kb/s |
6000 kb/s |
1080p |
|
|
3000 kb/s |
7000 kb/s |
Example configuration¶
The following example shows a configuration for the WebRTC streamer:
{
"video": {
"bitrate_limits": [
{ "num_pixels": 921600, "fps": 60, "min_kbps": 1000, "max_kbps": 4500 }
],
"nvidia_h264": {
"multipass": true,
"aq": true,
"aq_strength": 5
}
}
}
The num_pixels
value here is calculated based on a 720p resolution, thus 1280 * 720 = 921600
.