You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
srs/README.md

67 KiB

SRS(Simple Realtime Server)

SRS/4.0Leo是一个简单高效的实时视频服务器支持RTMP/WebRTC/HLS/HTTP-FLV/SRT/GB28181。

SRS is a simple, high efficiency and realtime video server, supports RTMP/WebRTC/HLS/HTTP-FLV/SRT/GB28181.

SRS is licenced under MIT, but some depended libraries are distributed using their own licenses.

Usage

Run SRS by docker, images is here or there, please set the CANDIDATE (CN,EN) if WebRTC enabled:

docker run --rm -it -p 1935:1935 -p 1985:1985 -p 8080:8080 \
    --env CANDIDATE=$(ifconfig en0 inet| grep 'inet '|awk '{print $2}') -p 8000:8000/udp \
    ossrs/srs:v4.0.117 ./objs/srs -c conf/srs.conf

Or build SRS from source(or mirrors), by CentOS7(or Linux(CN,EN)):

git clone -b 4.0release https://gitee.com/ossrs/srs.git &&
cd srs/trunk && ./configure && make && ./objs/srs -c conf/srs.conf

Open http://localhost:8080/ to check it, then publish stream by FFmpeg. It's also able to publish by H5 if WebRTC is enabled:

docker run --rm -it --network=host ossrs/srs:encoder \
  ffmpeg -re -i ./doc/source.flv -c copy -f flv -y rtmp://localhost/live/livestream

Play the following streams by players:

From here, please read wikis:

  • SRS 4.0 English Wiki, please read Wiki first.
  • SRS 4.0 中文Wiki不读Wiki一定扑街不读文档请不要提Issue不读文档请不要提问题任何文档中明确说过的疑问都不会解答。

Fast index for Wikis:

  • How to deliver RTMP streaming?(CN, EN)
  • How to build RTMP Edge-Cluster?(CN, EN)
  • How to build RTMP Origin-Cluster?(CN, EN)
  • How to deliver HTTP-FLV streaming?(CN, EN)
  • How to deliver HLS streaming?(CN, EN)
  • How to deliver low-latency streaming?(CN, EN)
  • How to use WebRTC? (CN, EN)

Other important wiki:

  • Usage: How to publish GB28181 to SRS? #1500
  • Usage: How to delivery DASH(Experimental)?(CN, EN)
  • Usage: How to transode RTMP stream by FFMPEG?(CN, EN)
  • Usage: How to delivery HTTP FLV Live Streaming Cluster?(CN, EN)
  • Usage: How to ingest file/stream/device to RTMP?(CN, EN)
  • Usage: How to forward stream to other servers?(CN, EN)
  • Usage: How to improve edge performance for multiple CPUs? (CN, EN)
  • Usage: How to file a bug or contact us? (CN, EN)

Ports

The ports used by SRS, kernel services:

  • tcp://1935, for RTMP live streaming server(CN,EN).
  • tcp://1985, HTTP API server, for HTTP-API(CN, EN), WebRTC(CN, EN), etc.
  • tcp://8080, HTTP live streaming server, HTTP-FLV(CN, EN), HLS(CN, EN) as such.
  • udp://8000, WebRTC Media(CN, EN) server.

For optional HTTPS services, which might be provided by other web servers:

  • tcp://8088, HTTPS live streaming server.
  • tcp://1990, HTTPS API server.

For optional stream caster services, to push streams to SRS:

For external services to work with SRS:

Features

  • Using coroutine by ST, it's really simple and stupid enough.
  • Support cluster which consists of origin (CN,EN) and edge(CN, EN) server and uses RTMP as default transport protocol.
  • Origin server supports remuxing RTMP to HTTP-FLV(CN, EN) and HLS(CN, EN).
  • Edge server supports remuxing RTMP to HTTP-FLV(CN, EN). As for HLS(CN, EN) edge server, recomment to use HTTP edge server, such as NGINX.
  • Support HLS with audio-only(CN, EN), which need to build the timestamp from AAC samples, so we enhanced it please read #547.
  • Support HLS with mp3(h.264+mp3) audio codec, please read bug #301.
  • Support transmux RTMP to HTTP-FLV/MP3/AAC/TS, please read wiki(CN, EN).
  • Support ingesting(CN, EN) other protocols to SRS by FFMPEG.
  • Support RTMP long time(>4.6hours) publishing/playing, with the timestamp corrected.
  • Support native HTTP server(CN, EN) for http api and http live streaming.
  • Support HTTP CORS for js in http api and http live streaming.
  • Support HTTP API(CN, EN) for system management.
  • Support HTTP callback(CN, EN) for authentication and integration.
  • Support DVR(CN, EN) to record live streaming to FLV file.
  • Support DVR control module like NGINX-RTMP, please read #459.
  • Support EXEC like NGINX-RTMP, please read bug #367.
  • Support security strategy including allow/deny publish/play IP(CN, EN).
  • Support low latency(0.1s+) transport model, please read bug #257.
  • Support gop-cache(CN, EN) for player fast startup.
  • Support Vhost(CN, EN) and __defaultVhost__.
  • Support reloading(CN, EN) to apply changes of config.
  • Support listening at multiple ports.
  • Support forwarding(CN, EN) to other RTMP servers.
  • Support transcoding(CN, EN) by FFMPEG.
  • All wikis are writen in Chinese and English.
  • Enhanced json, replace NXJSON(LGPL) with json-parser(BSD), read #904.
  • Support valgrind and latest ARM by patching ST, read ST#1 and ST#2.
  • Support traceable and session-based log(CN, EN).
  • High performance(CN, EN) RTMP/HTTP-FLV, 6000+ connections.
  • Enhanced complex error code with description and stack, read #913.
  • Enhanced RTMP url which supports vhost in stream, read #1059.
  • Support origin cluster, please read #464, RTMP 302.
  • Support listen at IPv4 and IPv6, read #460.
  • Improve test coverage for core/kernel/protocol/service.
  • Support docker by srs-docker.
  • Support multiple processes by ReusePort(CN, EN), #775.
  • Support a simple mgmt console, please read srs-ngb.
  • [Experimental] Support playing stream by WebRTC, #307.
  • [Experimental] Support publishing stream by WebRTC, #307.
  • [Experimental] Support mux RTP/RTCP/DTLS/SRTP on one port for WebRTC, #307.
  • [Experimental] Support client address changing for WebRTC, #307.
  • [Experimental] Support transcode RTMP/AAC to WebRTC/Opus, #307.
  • [Experimental] Support AV1 codec for WebRTC, #2324.
  • [Experimental] Enhance HTTP Stream Server for HTTP-FLV, HTTPS, HLS etc. #1657.
  • [Experimental] Support push stream by GB28181, #1500.
  • [Experimental] Support DVR in MP4 format, read #738.
  • [Experimental] Support MPEG-DASH, the future live streaming protocol, read #299.
  • [Experimental] Support pushing MPEG-TS over UDP, please read bug #250.
  • [Experimental] Support pushing FLV over HTTP POST, please read wiki(CN, EN).
  • [Experimental] Support HTTP RAW API, please read #459, #470, #319.
  • [Experimental] Support SRT server, read #1147.
  • [Deprecated] Support pushing RTSP, please read bug #2304.
  • [Deprecated] Support Adobe HDS(f4m), please read wiki(CN, EN) and #1535.
  • [Deprecated] Support bandwidth testing, please read #1535.
  • [Deprecated] Support Adobe FMS/AMS token traverse(CN, EN) authentication, please read #1535.
  • [Removed] Support RTMP client library: srs-librtmp.
  • Enhanced forwarding with vhost and variables, #1342.
  • Support DVR to Cloud Storage, #1193.
  • Support transmux RTC to RTMP, #2093.
  • Support H.265 over RTMP and HLS, #465.
  • Support IETF-QUIC for WebRTC Cluster, #2091.
  • Improve RTC performance to 5K by multiple threading, #2188.
  • Support source cleanup for idle streams, #413.
  • Support change user to run SRS, #1111.
  • Support HLS variant, #463.

Remark: About the milestone and product plan, please read (CN, EN) wiki.

Chnagelogs

Please read CHANGELOG.

Releases

Compare

Comparing with other media servers, SRS is much better and stronger, for details please read Product(CN/EN).

Performance

The performance benchmark data and corelative commits are listed here.

Play RTMP benchmark

The data for playing RTMP was benchmarked by SB:

Update SRS Clients Type CPU Memory Commit
2014-12-07 2.0.67 10k(10000) players 95% 656MB code
2014-12-05 2.0.57 9.0k(9000) players 90% 468MB code
2014-12-05 2.0.55 8.0k(8000) players 89% 360MB code
2014-11-22 2.0.30 7.5k(7500) players 87% 320MB code
2014-11-13 2.0.15 6.0k(6000) players 82% 203MB code
2014-11-12 2.0.14 3.5k(3500) players 95% 78MB code
2014-11-12 2.0.14 2.7k(2700) players 69% 59MB -
2014-11-11 2.0.12 2.7k(2700) players 85% 66MB -
2014-11-11 1.0.5 2.7k(2700) players 85% 66MB -
2014-07-12 0.9.156 2.7k(2700) players 89% 61MB code
2014-07-12 0.9.156 1.8k(1800) players 68% 38MB -
2013-11-28 0.5.0 1.8k(1800) players 90% 41M -
Update SFU Clients Type CPU Memory Threads VM
2021-05-11 SRS/v4.0.105 4000 players ~94% x1 419MB 1 G5 8CPU
2021-05-11 NginxRTMP/v1.2.1 2400 players ~92% x1 173MB 1 G5 8CPU

Note: CentOS7, 600Kbps, ECS/G5-2.5GHZ(SkyLake), SRS/v4.0.105, NginxRTMP/v1.2.1.

Publish RTMP benchmark

The data for publishing RTMP was benchmarked by SB:

Update SRS Clients Type CPU Memory Commit
2014-12-04 2.0.52 4.0k(4000) publishers 80% 331MB code
2014-12-04 2.0.51 2.5k(2500) publishers 91% 259MB code
2014-12-04 2.0.49 2.5k(2500) publishers 95% 404MB code
2014-12-04 2.0.49 1.4k(1400) publishers 68% 144MB -
2014-12-03 2.0.48 1.4k(1400) publishers 95% 140MB code
2014-12-03 2.0.47 1.4k(1400) publishers 95% 140MB -
2014-12-03 2.0.47 1.2k(1200) publishers 84% 76MB code
2014-12-03 2.0.12 1.2k(1200) publishers 96% 43MB -
2014-12-03 1.0.10 1.2k(1200) publishers 96% 43MB -
Update SFU Clients Type CPU Memory Threads VM
2021-05-11 SRS/v4.0.105 2300 publishers ~89% x1 1.1GB 1 G5 8CPU
2021-05-11 NginxRTMP/v1.2.1 1300 publishers ~84% x1 198MB 1 G5 8CPU

Note: CentOS7, 600Kbps, ECS/G5-2.5GHZ(SkyLake), SRS/v4.0.105, NginxRTMP/v1.2.1.

Play HTTP FLV benchmark

The data for playing HTTP FLV was benchmarked by SB:

Update SRS Clients Type CPU Memory Commit
2014-05-25 2.0.171 6.0k(6000) players 84% 297MB code
2014-05-24 2.0.170 3.0k(3000) players 89% 96MB code
2014-05-24 2.0.169 3.0k(3000) players 94% 188MB code
2014-05-24 2.0.168 2.3k(2300) players 92% 276MB code
2014-05-24 2.0.167 1.0k(1000) players 82% 86MB -

RTC benchmark

The RTC benchmark data, by srs-bench:

Update SFU Clients Type CPU Memory Threads VM
2021-05-10 SRS/v4.0.105 2000 players ~94% x1 462MB 1 G7 2CPU
2021-05-10 SRS/v4.0.105 1000 players ~90% x1 180MB 1 G5 2CPU
2021-03-31 SRS/v4.0.87 800 players ~94% x1 444MB 1 G5 2CPU
2021-05-10 Janus/v0.11.1 700 players ~93% x2 430MB 24 G5 2CPU
2021-05-10 SRS/v4.0.105 1700 publishers ~92% x1 334MB 1 G7 2CPU
2021-05-10 SRS/v4.0.105 950 publishers ~92% x1 132MB 1 G5 2CPU
2021-03-31 SRS/v4.0.87 550 publishers ~86% x1 1.3GB 1 G5 2CPU
2021-05-10 Janus/v0.11.1 350 publishers ~93% x2 405MB 23 G5 2CPU

Note: CentOS7, 600Kbps, ECS/G5-2.5GHZ(SkyLake)/G7-2.7GHZ(IceLake), SRS/v4.0.87, SRS/v4.0.105, Janus/v0.11.1.

Latency benchmark

The latency between encoder and player with realtime config(CN, EN):

Update SRS Protocol VP6 H.264 VP6+MP3 H.264+MP3
2014-12-16 2.0.72 RTMP 0.1s 0.4s 0.8s 0.6s
2014-12-12 2.0.70 RTMP 0.1s 0.4s 1.0s 0.9s
2014-12-03 1.0.10 RTMP 0.4s 0.4s 0.9s 1.2s
2021-04-02 4.0.87 WebRTC x 80ms x x

2018-08-05, c45f72e, Refine HTTP-FLV latency, support realtime mode. 2.0.252

We used FMLE as encoder for benchmark. The latency of server was 0.1s+, and the bottleneck was the encoder. For more information, read bug #257.

Architecture

The stream architecture of SRS.

+----------+             +----------+
| Upstream |             |  Deliver |
+---|------+             +----|-----+
+---+------------------+------+---------------------+----------------+
|     Input            | SRS(Simple RTMP Server)    |     Output     |
+----------------------+----------------------------+----------------+
|                      |   +-> DASH ----------------+-> DASH player  |
|    Encoder(1)        |   +-> RTMP/HDS  -----------+-> Flash player |
|  (FMLE,OBS,   --RTMP-+->-+-> HLS/HTTP ------------+-> M3U8 player  |
|  FFmpeg,XSPLIT,      |   +-> FLV/MP3/Aac/Ts ------+-> HTTP player  |
|  ......)             |   +-> Fowarder ------------+-> RTMP server  |
|                      |   +-> Transcoder ----------+-> RTMP server  |
|                      |   +-> EXEC(5) -------------+-> External app |
|                      |   +-> DVR -----------------+-> FLV file     |
|                      |   +-> BandwidthTest -------+-> Flash        |
|                      |   +-> WebRTC --------------+-> Flash        |
+----------------------+                            |                |
|    WebRTC Client     |   +--> RTMP                |                |
| (H5,Native...) --RTC-+---+---> WebRTC ------------+-> WebRTC Client|
+----------------------+                            |                |
|  MediaSource(2)      |                            |                |
|  (RTSP,FILE,         |                            |                |
|   HTTP,HLS,   --pull-+->-- Ingester(3) -(rtmp)----+-> SRS          |
|   Device,            |                            |                |
|   ......)            |                            |                |
+----------------------+                            |                |
|  MediaSource(2)      |                            |                |
|  (MPEGTSoverUDP      |                            |                |
|   HTTP-FLV,   --push-+->- StreamCaster(4) -(rtmp)-+-> SRS          |
|   GB28181,SRT,       |                            |                |
|   ......)            |                            |                |
+----------------------+                            |                |
|  FFMPEG --push(srt)--+->- SRTModule(5)  ---(rtmp)-+-> SRS          |
+----------------------+----------------------------+----------------+

Remark:

  1. Encoder: Encoder pushs RTMP stream to SRS.
  2. MediaSource: Supports any media source, ingesting by ffmpeg.
  3. Ingester: Forks a ffmpeg(or other tools) to ingest as rtmp to SRS, please read Ingest.
  4. Streamer: Remuxs other protocols to RTMP, please read Streamer.
  5. EXEC: Like NGINX-RTMP, EXEC forks external tools for events, please read ng-exec.
  6. SRTModule: A isolate module which run in hybrid model.

AUTHORS

There are two types of people that have contributed to the SRS project:

  • Maintainers: Contribute and maintain important features. SRS always remembers and thanks you by writing your names in stream metadata.
  • Contributors: Submit patches, report bugs, add translations, help answer newbie questions, and generally make SRS much better.

Maintainers of SRS project:

A big THANK YOU goes to:

Mirrors

Gitee: https://gitee.com/ossrs/srs, the GIT usage(CN, EN)

git clone https://gitee.com/ossrs/srs.git &&
cd srs && git remote set-url origin https://github.com/ossrs/srs.git && git pull

Remark: For users in China, recomment to use mirror from CSDN or OSChina, because they are much faster.

Gitlab: https://gitlab.com/winlinvip/srs-gitlab, the GIT usage(CN, EN)

git clone https://gitlab.com/winlinvip/srs-gitlab.git srs &&
cd srs && git remote set-url origin https://github.com/ossrs/srs.git && git pull

Github: https://github.com/ossrs/srs, the GIT usage(CN, EN)

git clone https://github.com/ossrs/srs.git
Branch Cost Size CMD
3.0release 2m19.931s 262MB git clone -b 3.0release https://gitee.com/ossrs/srs.git
3.0release 0m56.515s 95MB git clone -b 3.0release --depth=1 https://gitee.com/ossrs/srs.git
develop 2m22.430s 234MB git clone -b develop https://gitee.com/ossrs/srs.git
develop 0m46.421s 42MB git clone -b develop --depth=1 https://gitee.com/ossrs/srs.git
min 2m22.865s 217MB git clone -b min https://gitee.com/ossrs/srs.git
min 0m36.472s 11MB git clone -b min --depth=1 https://gitee.com/ossrs/srs.git

System Requirements

Supported operating systems and hardware:

  • All Linux, both 32 and 64 bits
  • Other OS, such as Windows, please use docker.

Beijing, 2013.10
Winlin