• Product
  • Demo
  • Resource
MPS Logo
Tencent MPS Blog
Tencent MPS Blog
Learn

Unlock Streaming Efficiency: SRS - The Simple Real-Time Video Server

Tencent MPS - Dev Team

SRS (Simple Realtime Server) is an open-source real-time video server and one of the most popular and active open-source projects in the global streaming server domain. It is primarily used in areas such as live streaming, WebRTC, and transportation. SRS supports commonly used streaming protocols and conversions, and its user-friendly and easy-to-use nature has earned it a good reputation among developers worldwide. The cloud-based SRS open-source audio and video solution, which is ready to use out of the box, has empowered numerous industries to explore new possibilities.

What is SRS

The role of SRS is to receive streams, perform protocol conversion, and distribute streams. It supports multiple streams, cloud-native operations, and has a comprehensive toolchain.

SRS Arch

The core capabilities of SRS include:

  1. Configuration: Supports NGINX-style conf file configuration, reload, and change detection for K8s ConfigMap. SRS 5.0 introduced environment variable configuration for easier deployment in cloud-native environments.
  2. OpenAPI: Provides HTTP API and callback support, including statistics for various protocols such as WebRTC and HLS. SRS 5.0 introduced Prometheus Exporter for cloud-native observability.
  3. Cluster: Supports Origin server cluster and Edge server cluster for live streaming. SRS 6.0 is currently developing Proxy cluster support for easier deployment of protocols like WebRTC and SRT in Kubernetes (K8s) environments.
  4. Logging and Errors: Context-based logging leverages SRS's lightweight thread technology, allowing quick access to context-specific logs. Error messages with stack traces facilitate troubleshooting. SRS 5.0 logs stack traces in case of crashes.
  5. Toolchain: Includes approximately 560 UTests with around 60% coverage, full pipeline testing and release processes, black-box testing based on FFprobe, and the SB (srs-bench) toolchain for live streaming and RTC load testing. SRS 5.0 introduced Asan, and SRS 6.0 is developing tea, which uses eBPF for network simulation and load balancing.
  6. Core Protocols: Supports RTMP, HLS, HTTP-FLV, HTTP-TS, WebRTC, SRT, MPEG-DASH, and other protocols, as well as protocol conversion. SRS 5.0 supports WHIP and integration with WordPress/Unity WebRTC.
  7. Encoding: Supports AAC and Opus for audio, audio transcoding, H.264, AV1, and HEVC for video. SRS 5.0 fully supports HEVC and 8K live streaming.
  8. Platforms: Supports common operating systems such as Linux, macOS, and Windows, as well as various CPUs including x86, armv7, aarch64, m1, RISCV, loongarch, and MIPS. It is also compatible with various operating systems.
  9. Performance and Latency: Supports up to 3K concurrent live streams or 1K RTC streams on a single core, with the ability to leverage multi-core capabilities in a clustered architecture. SRS 5.0 improved the underlying architecture and introduced multi-threading capabilities (still within a single process). The latency for RTMP or FLV is around 3 seconds, HLS or DASH is around 5 seconds, SRT and GB are around 500ms, and WebRTC latency is around 150ms.

SRS is not just a server with streaming capabilities; it is also a highly convenient and user-friendly streaming server.

SRS and SRT

SRT (Secure Reliable Transport) is an open-source, royalty-free UDP-based transport protocol developed by Haivision in collaboration with Wowza. Its purpose is to address the high latency and poor jitter resistance of TCP in long-distance link transmission, providing a secure and reliable solution. SRT is optimized for live streaming media scenarios, particularly in the OTT industry.

In terms of transmission quality metrics, SRT achieves fewer application-layer packet losses through more precise and faster retransmission control. It also incorporates a Pacing mechanism specifically designed for live streaming media scenarios. Even at a 50% packet loss rate, SRT ensures stable transmission compared to QUIC.

In SRS 5.0, SRT API has been refactored to support coroutines, enabling better integration with SRS's coroutine IO framework. It also supports HTTP callbacks and improves error handling, enhancing stability. Thanks to the efforts of the entire community, SRT's significance within SRS continues to grow.

Tencent Cloud has made specific optimizations for SRT and applied them in products such as StreamLink. Additionally, Tencent Cloud has made the following optimizations for remote transmission across regions:

  1. Connection Mechanism Optimization: Supports 0RTT/1RTT to optimize connection latency.
  2. Retransmission Mechanism Optimization: Optimizes retransmission rates through parameter optimization and sequence number control strategies.
  3. Congestion Control Optimization: Supports congestion control algorithms such as BBR and GCC adapt to different network scenarios.
  4. Multi-Link Transmission with Bandwidth Aggregation: While native SRT supports backup and broadcast modes for multi-link transmission, Tencent Cloud has added an auto-adaptive mode specifically for live streaming scenarios. This mode allows aggregation of bandwidth from multiple network interfaces for live streaming and intelligently selects the optimal link dynamically.

SRS and WebRTC

SRS 4.0 introduced support for the WebRTC protocol, UDP single-port multiplexing, client IP address switching, and RTMP to WebRTC conversion. This expansion allowed SRS to enter the realm of communication and low-latency live streaming, addressing the challenge of live streaming through web browsers after the discontinuation of Flash player.

It's also noteworthy that the Unity game framework now supports the WebRTC SDK. SRS has released an open-source srs-unity integration example, enabling integration with Unity. This integration facilitates various scenarios such as game live streaming, game communication, VR audio, and video, reducing the barriers for Unity developers to utilize audio and video capabilities.

Tencent Cloud has made enhancements to the SRT protocol stack in SRS 5.0 and optimized the SRT to WebRTC conversion path. In addition to RTMP to WebRTC conversion, Tencent Cloud also provides the capability to convert SRT to WebRTC. Furthermore, Tencent Cloud has contributed to the implementation of the WebRTC over TCP protocol. This allows for fallback to TCP protocol transmission when UDP is not feasible in certain network environments.

Low-latency live streaming with SRS

Low-latency live streaming is typically achieved through RTMP to HTTP-FLV or RTMP to WebRTC conversion, which can reduce the latency to the level of seconds. HTTP-FLV is widely used in world, while WebRTC offers even lower latency but may have less compatibility compared to FLV.

Tencent Cloud was one of the initial contributors to WebRTC and RTMP conversion in SRS, and has made subsequent contributions to frame grouping and other logic, addressing various issues in WebRTC to RTMP conversion.

In addition, SRT is widely used in low-latency live streaming scenarios. For example, low-latency switching can achieve delays of 300 to 500ms. Users can choose to push SRT streams to SRS servers using FFmpeg/OBS/vMix, and then use ffplay/vMix to pull the streams or watch them through a WebRTC-enabled webpage.

Furthermore, Tencent Cloud's cloud services and open-source projects are aligned, allowing for smooth migration to Tencent Cloud Live Event Broadcasting when business scales up, supporting larger-scale low-latency live streaming services.

SRS and H.265

SRS 6.0 supports H.265. H.265 can save up to 50% bandwidth compared to H.264. It offers significant advantages in 8K or VR scenarios, where H.264 cannot support high resolutions like 8K.

The open-source ecosystem for H.265 is gradually improving, and Chrome 105 already supports H.265 playback. Users can use FFmpeg to push SRT streams to SRS servers, convert SRT to HTTP-TS, and then play the live stream directly using VLC/ffplay or Chrome/mpegts.js.

SRS also supports the open-source WordPress SrsPlayer plugin, and FLV/MP4 file recording, all of which include H.265 encoding and decoding capabilities.

Tencent Cloud has made significant contributions to the H.265 direction in the open-source community. For example, Tencent Cloud have contributed to FFmpeg's H.265 mobile hardware acceleration and transparent video encoding/decoding. Tencent Cloud has also participated in Codec Review for multiple Pull Requests in SRS that support H.265. Tencent Cloud cloud service also supports H.265, allowing developers to seamlessly switch from open-source solutions to cloud services.

Cloud SRS

Cloud SRS is an open-source video cloud solution specifically designed for non-audio/video developers. It allows users to easily set up a ready-to-use video cloud platform with just a few mouse clicks. Cloud SRS supports various scenarios such as private live streaming rooms, unmanned live streaming, multi-platform streaming, low-latency live streaming, and recording.

Cloud SRS is an all-in-one video cloud solution that incorporates open-source products like SRS, FFmpeg, Nginx, and Redis. It provides a hassle-free setup for a standalone video cloud platform. Cloud SRS offers installation options such as the aaPanel plugin installation and Docker image installation.

Cloud SRS supports recording, allowing live streams to be saved as local files. In cases where local disk space is limited, Cloud SRS supports recording to Cloud Object Storage, eliminating concerns about running out of disk space.

Tencent Cloud closely collaborates with the Cloud SRS community to implement various application scenarios, and there are plans to continuously introduce new application scenarios in the future.

Observability of SRS

SRS 5.0 introduced official Prometheus Exporter support, enabling powerful observability for cloud-native environments and making SRS a more manageable service. This feature has played a crucial role in troubleshooting and issue resolution.

Tencent Cloud Collaboration with the SRS Community

Tencent Cloud holds two seats among the ten Core Maintainers (TOC) of SRS and has played a significant role in Codec Review and technical Roadmap discussions. Tencent Cloud has contributed to one of the core features of SRS 5.0, the coroutine transformation of SRT. This enhancement has provided comprehensive functionality to SRT, including callbacks and APIs, improved the underlying SRT IO mechanism, and integrated SRS's coroutine framework. These improvements have increased the efficiency, stability, and usability of SRT.

If you are interested in the SRS open-source project or our products, please feel free to contact us.

Stream