Adaptive bitrate streaming
  • 11 May 2022
  • 2 Minutes to read
  • Dark
    Light

Adaptive bitrate streaming

  • Dark
    Light

Adaptive bitrate streaming (aka. dynamic adaptive streaming or multi-bitrate streaming) allows you to deliver the optimum video quality according to the network bandwidth between you and the media server. This enables users to play videos smoothly regardless of their internet connection speed or device.

Why use adaptive bitrate

More people are getting connected to the internet and more videos are viewed each day. However, there may be issues as internet connection speeds may not let watching videos in high quality. In this case, player needs buffering and this makes viewers wait while watching the video.

But there may be an issue about watching video on internet because internet connection speeds usually does not let watching videos in high quality so that player needs buffering and this make you to wait while watching video.

In order to provide a better user experience, service providers create lower resolutions of the videos to make people watch videos seamlessly even if their network condition is not good enough to watch HD videos. This way that you do not have to wait for the player to buffer, thanks to adaptive streaming.

Adaptive bitrate on the fly

Lowering the resolutions of videos for recorded streams is not a big deal. However, doing the same job for live streams on the fly is not as easy as recorded streams. Thankfully, Ant Media Server supports adaptive bitrate streaming in Enterprise Edition and live streams can be played with WebRTC and HLS (HTTP Live Streaming).

How WebRTC & HLS adaptive streaming works

AMS supports adaptive streaming in both WebRTC and HLS formats. On the other hand, there is a slight difference between WebRTC and HLS adaptive streaming. In WebRTC, Ant Media Server measures the player's bandwidth and selects the optimum quality according to the player's bandwidth. In HLS, the player measures its bandwidth and fetches the optimum quality from the server.

How to enable adaptive bitrate

1. From the dashboard

Go to App > Settings > Adaptive Bitrate and enable adaptive streaming, and add new streams.

Note:
Adaptive streaming detects the bandwidth and CPU capacity of the device and adjusts the streaming rate and video quality appropriately. Therefore you'll see a higher CPU load and we recommend enabling GPU for AMS.

Quick Link: Learn How to Enable GPU for Ant Media Server

The configuration above will create videos at 1080p, 720p and 360p resolutions if the incoming stream resolution is higher than 1080p. If the incoming stream resolution is 480p, then 480p and 360p versions of the stream will be created on the fly.

2. Using configuration file

Open the configuration file {INSTALL_DIR}/webapps/{APP_NAME}/WEB-INF/red5-web.properties with your favorite editor.

Now, add this line to the file: settings.encoderSettingsString=[{"videoBitrate":800000,"forceEncode":true,"audioBitrate":64000,"height":360},{"videoBitrate":500000,"forceEncode":true,"audioBitrate":32000,"height":240}]

The format of the file is as follows: resolution height, video bitrate per second, and audio bitrate per second. In the example above, we are adding two adaptive bitrates:

  1. 360p, 800Kbps video bitrate, 64Kbps audio bitrate
  2. 240p, 500Kbps video bitrate, 32Kbps audio bitrate

Save and close the file. After entering adaptive bitrate settings manually, you need to restart the Ant Media Server.

sudo service antmedia restart

Was this article helpful?