To improve the stream ingest effect of ApsaraVideo Live in poor network conditions, Push SDK adds support for stream ingest over the Real-Time Streaming (RTS) protocol that is based on Real-Time Communication (RTC). This topic compares the Real-Time Messaging Protocol (RTMP) protocol and RTS protocol for stream ingest in different network conditions. Compared with RTMP, RTS is more stable and performs better in poor network conditions. We recommend that you ingest streams over RTS. Push SDK provides a mechanism of automatic protocol degradation. If an error occurs when you ingest a stream over RTS, RTMP is used for stream ingest.
Comparison of RTMP and RTS for stream ingest in normal and poor network conditions
Testing scenario
The streamer uses Push SDK to ingest a stream, and viewers pull the stream from Alibaba Cloud points of presence (POPs). Various network restrictions are placed on the streamer side to observe the playback effect on the viewer side. The restrictions affect only the upstream bandwidth of the streamer, but not the downstream bandwidth of the streamer.
Stream ingest parameters
The same stream ingest parameters are used for RTMP and RTS.
Parameter | Value |
Resolution | 720 X 1280 |
Frame rate | 20 frames per second (FPS) |
Bitrate | 2 Mbit/s |
Network restrictions
Restriction | Description |
Upstream packet loss: 20% | 20% of packets sent upstream are lost. |
Upstream bandwidth: 500 Kbit/s | Up to 500 KB of data can be sent per second. |
Upstream latency: 500 ms | Packets are sent over the network at a latency of 500 milliseconds. |
Video stuttering rate
The following figure shows the video stuttering rates in different network conditions. A greater value indicates a higher stuttering rate. As shown in the figure, RTS provides a lower stuttering rate than RTMP in poor network conditions.
Video quality
The following figure shows the video qualities in different network conditions. A greater value indicates a higher video quality. As shown in the figure, RTS provides a better video quality than RTMP in poor network conditions.
Use Push SDK to ingest a stream over RTS
Prerequisites
ApsaraVideo Live is activated. An ingest domain and a streaming domain are added, and the ingest domain is associated with the streaming domain. For more information, see Get started with ApsaraVideo Live.
RTS-based stream ingest is enabled for the ingest domain. From September 1, 2022, RTS-based stream ingest is automatically enabled for ingest domains that you add. No additional configurations are required. For ingest domains that were added before September 1, 2022, you must manually enable RTS-based stream ingest.
Log on to the ApsaraVideo Live console.
In the left-side navigation pane, click Domain Names. The Domain Management page appears.
Find the ingest domain for which you want to enable RTS-based stream ingest and click Domain Settings in the Actions column.
On the page that appears, choose
.Turn on RTS-based Stream Ingest.
An ingest URL is generated. The rules for generating ingest URLs in the RTS format are similar to the rules for generating ingest URLs in the RTMP format, except that the schemes at the beginning are different. Ingest URLs in the RTS format must start with
artc://
. For more information, see Generate ingest and streaming URLs.
Ingest a stream over RTS
The procedure for using Push SDK to ingest an RTS stream is similar to the procedure for using Push SDK to ingest an RTMP stream. To ingest an RTS stream, you must specify an ingest URL in the RTS format when you call the startPush method. Other settings are the same. For more information, see Use Push SDK for Android or Use Push SDK for iOS.
Only audio and video streams are supported for stream ingest over RTS. In other word, an RTS stream must include both audio and video data. If you are ingesting an audio-only or video-only stream, you must add video data to the audio-only stream or audio data to the video-only stream before you can ingest the stream over RTS.
Play the stream
You can use the RTMP, Flash Video (FLV), or HTTP Live Streaming (HLS) protocol to play a stream that is ingested over RTS. You can also use the Alibaba Real-Time Communication (ARTC) protocol for playback at an ultra-low latency. For more information about RTS playback, see the "Start RTS-based stream ingest" section of the Get started with RTS topic.