SRS (Simple Realtime Server)

repository·develop·Indexed 12 days ago

https://github.com/ossrs/srs

A high-efficiency, real-time video server supporting multiple protocols including RTMP, WebRTC, HLS, and SRT. Designed for low-latency video streaming across various platforms and architectures, SRS supports integration with tools like FFmpeg and OBS.

Tokens
185.6K
Snippets
492
Records
874
Agent score
99%

What's inside SRS

  1. Overview of SRS Dockerfiles

    develop

    SRS uses several different Dockerfiles depending on the intended use case:

    • Dockerfile: Used for release and general testing.
    • trunk/Dockerfile.pkg: Used for creating package binaries.
    • trunk/Dockerfile.builds: Used for testing build processes.
    • trunk/Dockerfile.test: Used for running tests.
    • trunk/Dockerfile.cov: Used for testing and code coverage.
  2. Overview of the Googletest Mocking (gMock) Framework

    develop

    gMock is a C++ framework used for creating mock classes to facilitate better system design and testing. It provides a declarative syntax for defining mocks and allows for the creation of partial (hybrid) mocks that combine real and mock object behavior.

    Key capabilities include:

    • Argument Validation: Uses a rich set of matchers to validate function arguments.
    • Behavior Control: Provides intuitive syntax for controlling how mocks behave during tests.
    • Automatic Verification: Automatically verifies expectations without requiring a manual record-and-replay cycle.
    • Call Ordering: Supports expressing arbitrary (partial) ordering constraints on function calls.
    • Extensibility: Users can define custom matchers and actions.
    • Function Support: Handles overloaded functions and functions of arbitrary types.
    • Exception Safety: Does not use exceptions.

    Note: gMock is part of the GoogleTest C++ testing framework and is subject to its requirements.

  3. Overview of SRS (Simple Realtime Server)

    develop

    SRS is an open-source, high-efficiency, real-time video server. It operates on a typical publish (push) and subscribe (play) model, working with clients like FFmpeg, OBS, and VLC to receive and distribute streams.

    Supported Protocols

    • Live Streaming: RTMP, HLS, SRT, MPEG-DASH, and HTTP-FLV.
    • WebRTC: WebRTC, WHIP, and WHEP.
    • Other: GB28181.

    Protocol Conversion

    SRS can convert between various protocols, such as converting RTMP or SRT to HLS, HTTP-FLV, or WebRTC.

  4. What is Oryx

    develop

    Oryx (formerly SRS Stack) is an all-in-one, out-of-the-box, open-source video solution designed for creating live streaming and WebRTC services. It integrates several core technologies into a single-node application to provide a complete media workflow.

    Core Integrated Components:

    • SRS: The underlying media server for receiving, converting, and distributing streams.
    • FFmpeg: Handles heavy lifting like transcoding, restreaming, virtual live events, and AI media pipelines.
    • Go Backend: Manages workflows, authentication, and HTTP APIs.
    • React Dashboard: A web interface for configuration and operation.
    • Redis: Stores configuration and task state.
    • NGINX: Provides HTTP/HTTPS access and reverse proxying.
    • OpenAI (Optional): Powers AI features like transcription, dubbing, and OCR.
  5. What is Oryx (SRS Stack)?

    develop

    Oryx is an open-source, out-of-the-box video cloud solution (SRS Stack) built on Go, Reactjs, SRS, FFmpeg, and WebRTC. It is designed for various streaming scenarios including:

    • Push-Pull Streaming: Supports multiple protocols and can be embedded into websites like WordPress.
    • Recording (DVR): Supports merging multiple streams, applying filters, and saving to local disk or cloud storage.
    • Virtual Live Streaming: Allows using pre-recorded videos to simulate 24/7 live events.
    • Restreaming: Automatically forwards streams to multiple platforms (YouTube, Twitch, Facebook) with fault tolerance.
    • AI Features: Includes AI transcription (via OpenAI Whisper), VoD translation, and Stream OCR.
    • Automatic HTTPS: One-click enablement of HTTPS via Let's Encrypt, which is required for WebRTC and browser-based publishing.
  6. What is SRS and how it works

    develop

    SRS (Simple Realtime Server) is a high-efficiency, real-time media server designed to receive streams from publishers and deliver them to players.

    Workflow:

    1. Publishers (e.g., FFmpeg, OBS, Larix, Browsers via WHIP) push media streams to SRS.
    2. SRS processes and transmuxes the streams.
    3. Players (e.g., VLC, FFmpeg, Browsers, ExoPlayer) consume the streams from SRS.

    SRS supports various protocols for both input and output, allowing for protocol conversion (transmuxing) to suit different delivery needs.

    graph TD
        subgraph Publishers
            P["FFmpeg, OBS, Larix, vMix,<br/>hardware encoders, browsers, apps"]
        end
    
        S["SRS"]
    
        subgraph Players
            L["FFmpeg, VLC, ffplay, ExoPlayer,<br/>IJKPlayer, browsers, hardware, apps"]
        end
    
        Publishers --> S --> Players
  7. SRS Release Milestones

    develop

    SRS (Simple Realtime Server) follows a release cycle identified by specific codenames. For a detailed list of features available in each version, refer to the SRS Features documentation.

    /* Release History Summary */
    * Release 8.0 (2026~Now): Code: Free
    * Release 7.0 (2025~2026): Code: Kai
    * Release 6.0 (2023~2025): Code: Hang
    * Release 5.0 (2022~2023): Code: Bee
    * Release 4.0 (2020~2021): Code: Leo
    * Release 3.0 (2018~2019): Code: OuXuli
    * Release 2.0 (2015~2017): Code: ZhouGuowen
    * Release 1.0 (2013~2014): Code: HuKaiqun
  8. Key features of SRS 5.0

    develop

    SRS 5.0 introduced significant improvements to core streaming protocols and architecture:

    • ST (State-Threads): Multi-threading capabilities with support for Windows, RISCV, LOONGARCH, MIPS, and Apple M1 chips.
    • SRT: Rewritten using ST, supporting direct IP streaming, improved latency, and upgraded libsrt.
    • WebRTC: Supports WHIP and WHEP protocols, TCP transmission, and improved error reporting. Includes MP3 to OPUS conversion and native OPUS support in FFmpeg.
    • WHIP: Supports the WHIP protocol (compatible with Larix and OBS WHIP), includes security features, and supports resource deletion.
    • GB28181: Supports the 2016/TCP protocol.
    • Live Streaming: Improved RBSP parsing, FFmpeg timecode compatibility, HLS pseudo-streams, and HLS client kicking.
  9. Third-party dependencies for SRS features

    develop

    SRS relies on several third-party libraries to enable specific streaming and protocol features. Depending on your required functionality (e.g., WebRTC, HLS, or Transcoding), you may need to ensure these dependencies are available in your build environment.

    Feature-to-Dependency Mapping

    • HTTP Callbacks: Requires http-parser.
    • HLS Streaming: Requires nginx.
    • SRT Protocol: Requires srt.
    • RTMP Complex Handshake (with-ssl): Requires openssl (specifically for delivering H.264+AAC streams).
    • WebRTC (SRTP encryption/decryption): Requires openssl (version 1.0.*) and libsrtp.
    • RTMP/WebRTC Transcoding: Requires ffmpeg and opus.
    • Performance Benchmarking: Requires gperftools.
  10. Protocol Support and Capabilities in SRS

    develop

    SRS provides native support for several streaming protocols, each with specific use cases and limitations:

    Supported Protocols

    • RTMP: The most comprehensive implementation in SRS. Supports HEVC (for WebRTC conversion without audio transcoding), but AV1 and Opus support are currently pending.
    • WebRTC: A core protocol for browser-based streaming.
      • Current Limitations: Only supports NACK for congestion control (lacks FEC and GCC). Does not yet support Edge clusters (Origin clusters via Proxy are supported in SRS 7.0; Edge cluster support is targeted for SRS 8.0).
    • HLS: Widely used for segmented streaming.
      • Limitations: Does not support multiple bitrates (requires FFmpeg for transcoding), MP4 segments, or LLHLS.
    • DASH: Supported, including MP4 encapsulation, but noted as less reliable for live streaming compared to HLS.
    • SRT: Integrated via libsrt.
      • Usage: Primarily an ingress protocol. SRS supports SRT to RTMP and SRT to WebRTC conversion, but does not support RTMP to SRT conversion.
      • Limitations: Best suited for low concurrency due to UDP/TS overhead.
    • GB28181: Supports the GB28181 2016 (TCP) protocol stack. Used to stream to SRS for viewing via WebRTC.

    Deprecated or Unsupported Protocols

    • RTSP: Removed from SRS. While useful for AI/security camera integration, it lacks robust congestion control for internet transmission.
    • HDS: Considered nearly obsolete.
    • RTS/DASH: DASH is supported but has inherent design complexities for live streaming.
  11. Supported Client SDKs and Players

    develop

    SRS supports a wide range of client-side technologies for both publishing (encoding/streaming) and playing back live streams. The general workflow is:

    Encoder $\rightarrow$ SRS/CDN Network $\rightarrow$ Player.

    Supported technologies include:

    • Android/iOS Players:
      • EXOPlayer: Supports HTTP-FLV and HLS protocols.
      • IJKPlayer: A cross-platform player for Android and iOS.
    • Cross-Platform/Universal:
      • FFmpeg: Used for recording, converting, and streaming audio/video.
      • LIBRTMP / SRS-LIBRTMP: Provides transport specifically over the RTMP protocol.
      • WebRTC: For real-time communication on the web.
    • PC/Desktop:
      • OBS (Open Broadcaster Software): Used for publishing streams.
  12. HEVC/H.265 Support in SRS 6.0 (Hang)

    develop

    SRS 6.0 (codename: Hang) provides comprehensive HEVC (H.265) support across multiple delivery protocols and recording formats:

    • Streaming: HEVC over RTMP, HTTP-FLV, HLS, and SRT.
    • Recording (DVR):
      • Record H.265 streams to MP4 format.
      • Record H.265 streams to FLV fragments.

    Other 6.0 Features

    • WebRTC: WHEP support, OPUS stereo SDP support, and configurable AAC to Opus transcoding bitrates.
    • Security: IP Whitelisting for HTTP-FLV, HLS, WebRTC, and SRT; Basic Authentication for the HTTP API.
    • SRT: Upgraded to libsrt v1.5.3, configurable default_streamid, and reduced SRT-to-RTC latency (down to 200ms).
    • HLS: Ability to disconnect (kick-off) HLS clients.