All Products
Search
Document Center

ApsaraVideo Live:Reduce the latency to 200 to 400 ms

Last Updated:Sep 06, 2024

This topic describes how to reduce the live streaming latency to less than 400 ms based on Real-Time Streaming (RTS), providing a smooth and instant viewing experience.

Solution overview

RTS relies on Alibaba Cloud Global Realtime Transport Network (GRTN) to implement an end-to-end latency of 200 to 400 ms based on full-link Web Real-Time Communication (WebRTC). You can seamlessly upgrade from standard streaming to RTS. This way, forward compatibility is achieved.

image

Use RTS 2.0 to implement an end-to-end latency of 200 to 400 ms

  1. After collecting a live stream from a device, a streamer can use Push SDK to ingest the live stream to Alibaba Cloud points of presence (POPs) over the RTS protocol that is based on WebRTC.

  2. The live stream is transmitted among over 3,200 POPs of GRTN in real time based on the intelligent routing and quality of service (QoS) technologies.

  3. Viewers pull the live stream from the nearest POPs over the RTS protocol that is based on WebRTC and play the live stream. The end-to-end latency is 200 to 400 ms.

(Optional) Enable stream relay to implement media processing of streams that are based on RTS 1.0 and standard streaming

  1. After you enable stream relay, ApsaraVideo Live can automatically encapsulate the live stream that is ingested by the streamer and generate a Real-Time Messaging Protocol (RTMP) stream.

  2. You can configure media processing settings, such as transcoding, recording, and snapshot capture, for the live stream.

  3. If you want to have a low latency for stream pulling, use RTS 1.0. This way, viewers can pull the live stream over the RTS protocol that is based on WebRTC. The end-to-end latency is 500 to 1,000 ms.

  4. If you use standard streaming, viewers can pull the live stream over protocols such as RTMP, Flash Video (FLV), and HTTP Live Streaming (HLS).

Solution implementation

Prerequisites

  • ApsaraVideo Live is activated. For more information, see Activate ApsaraVideo Live.

  • An ingest domain and a streaming domain for ApsaraVideo Live are configured. For more information, see the Add an ingest domain and a streaming domain, Add CNAME records, and Associate the streaming domain with the ingest domain steps in Get started with ApsaraVideo Live.

Configure HTTPS certificates for the ingest domain and streaming domain

In this topic, a demo for web browsers is used as an example to show you how to pull and ingest streams. In this case, you must configure HTTPS certificates for the ingest domain and streaming domain due to security concerns for WebRTC. For more information, see Configure HTTPS secure acceleration.

If you use Native RTS SDK for stream ingest and playback, you do not need to configure HTTPS certificates.

Configure RTS 2.0 for the streaming domain

  1. Log on to the ApsaraVideo Live console.

  2. In the left-side navigation pane, click Domain Names. The Domain Management page appears.

  3. Find the streaming domain that you want to configure and click Domain Settings in the Actions column.002

  4. On the page that appears, choose Streaming Management > RTS.

  5. Click Modify. In the dialog box that appears, set Version to RTS 2.0 and Scenario to Live Stream Viewing.RTS2.0

  6. Click OK.

Configure RTS 2.0 for the ingest domain

  1. Log on to the ApsaraVideo Live console.

  2. In the left-side navigation pane, click Domain Names. The Domain Management page appears.

  3. Find the ingest domain that you want to configure and click Domain Settings in the Actions column.域名配置

  4. On the page that appears, choose Streaming Management > RTS-based Stream Ingest.

  5. Click Modify. In the dialog box that appears, set Version to RTS 2.0 for Stream Ingest.推流rts 2.0

  6. Click OK.

Generate ingest and streaming URLs

In the feature verification phase, you can use the URL generator to generate ingest and streaming URLs. For more information, see Live URL generator.

You can also construct ingest and streaming URLs by using the concatenation rules. For more information, see Generate ingest and streaming URLs.

地址生成器

Implement RTS-based stream ingest on the streamer side

You can use one of the following SDKs to ingest streams over RTS.

SDK

References

Push SDK for iOS

Push SDK for iOS

Note

By default, Push SDK for iOS supports stream ingest that is based on WebRTC.

Push SDK for Android

Push SDK for Android

Note

By default, Push SDK for Android supports stream ingest that is based on WebRTC.

Third-party SDKs based on standard WebRTC

Specifications of WebRTC signaling used to access GRTN

In the following example, the RTS demo for web is used to ingest a stream over RTS.

  1. Open the RTS demo for web page.

  2. In the demo, select the Stream Ingest mode.

  3. Expand the none drop-down box and select camera or screen based on your business requirements.

    If you select camera, click Mic and Camera at the bottom of the page to authorize the player to access your devices. After the authorization is successful, expand the Select Microphone and Select Camera drop-down boxes to select corresponding devices.

  4. Enter the ingest URL in the RTS format that is generated in Generate ingest and streaming URLs and click Create Local Stream.

  5. Click Start to start stream ingest.RTS推流

Implement RTS playback on the viewer side

You can use one of the following SDKs to play streams over RTS.

SDK

References

Web RTS SDK

Overview of Web RTS SDK

Native RTS SDK for iOS

Overview of Native RTS SDK

Native RTS SDK for Android

Overview of Native RTS SDK

Native RTS SDK for macOS

Native RTS SDK for macOS

Native RTS SDK for Windows

Native RTS SDK for Windows

Third-party SDKs based on standard WebRTC

Specifications of WebRTC signaling used to access GRTN

In the following example, the RTS demo for web is used to play a stream over RTS.

  1. Open the RTS demo for web page.

  2. In the demo, select the Stream Pulling mode.

  3. Enter the streaming URL in the RTS format that is generated in Generate ingest and streaming URLs.

  4. Click Start to start stream pulling.rts 播放

(Optional) Configure stream relay

  1. Log on to the ApsaraVideo Live console.

  2. In the left-side navigation pane, click Domain Names. The Domain Management page appears.

  3. Find the ingest domain that you want to configure and click Domain Settings in the Actions column.域名配置

  4. On the page that appears, choose Streaming Management > RTS-based Stream Ingest.

  5. Click Modify. In the dialog box that appears, set Version to RTS 2.0 for Stream Ingest, turn on Stream Relay, and select another domain name to which RTMP streams are relayed.

    For example, if you set the Relayed To parameter to push.example.com, whose associated streaming domain is pull.example.com, take note of the following points:

    • You cannot enable RTS 2.0 for push.example.com and pull.example.com.

    • You are not charged additional fees for this feature.

    转推

(Optional) Configure media processing templates for relayed streams

After you configure stream relay, you can configure media processing templates for the streaming domain that is associated with the ingest domain to which streams are relayed. In this example, the streaming domain is pull.example.com.

On the domain name management page, click Templates and configure templates based on your business requirements.模板配置

(Optional) Use RTS 1.0 and standard streaming for relayed streams

After you configure stream relay, you can use RTS 1.0 and standard streaming for the streaming domain that is associated with the ingest domain to which streams are relayed. This way, you can play the source streams or transcoded streams over RTS and RTMP, FLV, and HLS at the same time. In this example, the streaming domain is pull.example.com.

  • For more information about standard streaming, see Get started with ApsaraVideo Live.

  • From September 1, 2022, all streaming domains support playback based on RTS 1.0 by default. You need only to integrate RTS SDK on the playback side. For more information, see Get started with RTS.