xialixin / srs

SRS is an industrial-strength live cluster, with simple code and best conceptual integrity.
MIT License
11 stars 4 forks source link

SRS

SRS/4.0,Leo,是一个流媒体集群,支持RTMP/HLS/WebRTC/SRT/GB28181,高效、稳定、易用,简单而快乐。
SRS is a RTMP/HLS/WebRTC/SRT/GB28181 streaming cluster, high efficiency, stable and simple.

Remark: Although SRS is licenced under MIT, but there are some depended libraries which are distributed using their own licenses, please read License Mixing.

Usage

>>> Step 1: Get SRS.

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

Note: We use mirrors(gitee) here, but it's also ok to directly clone by git clone https://github.com/ossrs/srs.git && cd srs/trunk

>>> Step 2: Build SRS.

./configure && make

Remark: Recommend to use Centos7 64bits, please read wiki(CN,EN).

Note: You can also build SRS in docker, please read docker.

>>> Step 3: Run SRS

./objs/srs -c conf/srs.conf

>>> Whatever, you can also directly run SRS in docker:

docker run -p 1935:1935 -p 1985:1985 -p 8080:8080 \
    registry.cn-hangzhou.aliyuncs.com/ossrs/srs:3

Note: Again, we use ACR here, you can directly run in docker hub by docker run -p 1935:1935 -p 1985:1985 -p 8080:8080 ossrs/srs:3

>>> From here, strongly recommend to read bellow wikis:

Wiki

Please select according to languages:

For previous versions, please read:

Features

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

V4 changes

V3 changes

V2 changes

V1 changes

Releases

Compare

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

Stream Delivery

Feature SRS NGINX CRTMPD AMS WOWZA
RTMP Stable Stable Stable Stable Stable
HLS Stable Stable X Stable Stable
HTTP FLV Stable X X X X
HLS(aonly) Stable X X Stable Stable
HDS Experiment X X Stable Stable
MPEG-DASH Experiment X X X X
SRT Experiment X X X Stable
HTTP Server Stable Stable X X Stable

Cluster

Feature SRS NGINX CRTMPD AMS WOWZA
RTMP Edge Stable X X Stable X
RTMP Backup Stable X X X X
VHOST Stable X X Stable Stable
Reload Stable X X X X
Forward Stable X X X X
ATC Stable X X X X
Docker Stable X X X X

Stream Service

Feature SRS NGINX CRTMPD AMS WOWZA
DVR Stable Stable X X Stable
DVR API Stable Stable X X X
DVR MP4 Stable X X X X
EXEC Stable Stable X X X
Transcode Stable X X X Stable
HTTP API Stable Stable X X Stable
HTTP RAW API Stable X X X X
HTTP hooks Stable X X X X
GopCache Stable X X Stable X
Security Stable Stable X X Stable
Token Traverse Stable X X Stable X

Efficiency

Feature SRS NGINX CRTMPD AMS WOWZA
Concurrency 7.5k 3k 2k 2k 3k
MultipleProcess Stable Stable X X X
RTMP Latency 0.1s 3s 3s 3s 3s
HLS Latency 10s 30s X 30s 30s

Stream Caster

Feature SRS NGINX CRTMPD AMS WOWZA
Ingest Stable X X X X
Push MPEGTS Experiment X X X Stable
Push RTSP Experiment X Stable X Stable
Push HTTP FLV Experiment X X X X

Debug System

Feature SRS NGINX CRTMPD AMS WOWZA
BW check Stable X X X X
Tracable Log Stable X X X X

Docs

Feature SRS NGINX CRTMPD AMS WOWZA
Demos Stable X X X X
WIKI(EN+CN) Stable EN only X X Stable

Others

Feature SRS NGINX CRTMPD AMS WOWZA
ARM/MIPS Stable Stable X X X
Client Library Stable X X X X

Remark:

  1. Concurrency: We only benchmark the concurrency of single process.
  2. MultipleProcess: SRS supports multiple processes by go-oryx.
  3. HLS aonly: HLS supports audio only mode without video stream.
  4. BW check: The bandwidth check feature is used to detect the bandwidth between server and client.
  5. Security: The security includes access control, token authentication and referer check.
  6. Reload: SRS and Nginx supports reload, but nginx-rtmp doesn't.

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 -

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 -

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 -

Latency benchmark

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

Update SRS VP6 H.264 VP6+MP3 H.264+MP3
2014-12-16 2.0.72 0.1s 0.4s 0.8s 0.6s
2014-12-12 2.0.70 0.1s 0.4s 1.0s 0.9s
2014-12-03 1.0.10 0.4s 0.4s 0.9s 1.2s

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.

HLS overhead

About the overhead of HLS overhead, we compared FFMPEG and SRS.

Bitrate Duration FLV(KB) HLS(KB) Overhead
275kbps 600s 11144 12756 14.46%
260kbps 1860s 59344 68004 14.59%
697kbps 60s 5116 5476 7.03%
565kbps 453s 31316 33544 7.11%
565kbps 1813s 125224 134140 7.12%
861kbps 497s 52316 54924 4.98%
857kbps 1862s 195008 204768 5.00%
1301kbps 505s 80320 83676 4.17%
1312kbps 1915s 306920 319680 4.15%
2707kbps 600s 198356 204560 3.12%
2814kbps 1800s 618456 637660 3.10%
2828kbps 60s 20716 21356 3.08%
2599kbps 307s 97580 100672 3.16%
2640kbps 1283s 413880 426912 3.14%
5254kbps 71s 45832 47056 2.67%
5147kbps 370s 195040 200280 2.68%
5158kbps 1327s 835664 858092 2.68%

The HLS overhead is calc by: (HLS - FLV) / FLV * 100%.

The overhead should be larger than this benchmark(48kbps audio is best overhead), for we fix the #512.

Architecture

SRS always use the simplest architecture to solve complex domain problems.

System Architecture

+------------------------------------------------------+
|                    Application                       |
|            Origin/Edge/HTTP-FLV/StreamCaster         |
+---------------+---------------+-----------+----------+
|   RAW API/    |     EXEC/     |  DVR/HLS  | FLV/TS/  |
|   API/hook    |   Transcoder  |  HDS/DASH | AMF0/JSON|
+---------------+---------------+-----------+ RTMP/RTSP|
|  http-parser  |  FFMPEG/x264  |  NGINX/ts | protocol |
+---------------+---------------+-----------+----------+
|              Network(state-threads)                  |
+------------------------------------------------------+
|    All Linux/Unix(RHEL,CentOS,Ubuntu,Fedora...)      |
+------------------------------------------------------+

Modularity Architecture

+--------------------+---------------------------------+
|   SRS/SRT server   |       Programs in Main          |
+--------------------+-------+-------------------------+
|  App(For SRS)              |      Modules(1)         |
+----------------------------+-------------------------+
|   Protocol Stack(RTMP/HTTP/RTSP/JSON/AMF/Service)    |
+------------------------------------------------------+
|      Kernel(File, Codec, Stream, LB services)        |
+------------------------------------------------------+
|         Core(Macros and very low-level APIs)         |
+------------------------------------------------------+

Remark:

  1. Modules: SRS supports code-level modularity, read modules.

Stream Architecture

+---------+              +----------+
| Publish |              |  Deliver |
+---|-----+              +----|-----+
+----------------------+----------------------------+----------------+
|     Input            | SRS(Simple RTMP Server)    |     Output     |
+----------------------+----------------------------+----------------+
|                      |   +-> DASH ----------------+-> DASH player  |
|    Encoder(1)        |   +-> RTMP/HDS  -----------+-> Flash player |
|  (FMLE,FFMPEG, -rtmp-+->-+-> HLS/HTTP ------------+-> M3U8 player  |
|  Flash,XSPLIT,       |   +-> FLV/MP3/Aac/Ts ------+-> HTTP player  |
|  ......)             |   +-> Fowarder ------------+-> RTMP server  |
|                      |   +-> Transcoder ----------+-> RTMP server  |
|                      |   +-> EXEC(5) -------------+-> External app |
|                      |   +-> DVR -----------------+-> FLV file     |
|                      |   +-> BandwidthTest -------+-> Flash        |
+----------------------+                            |                |
|  MediaSource(2)      |                            |                |
|  (RTSP,FILE,         |                            |                |
|   HTTP,HLS,   --pull-+->-- Ingester(3) -(rtmp)----+-> SRS          |
|   Device,            |                            |                |
|   ......)            |                            |                |
+----------------------+                            |                |
|  MediaSource(2)      |                            |                |
|  (RTSP,FILE,         |                            |                |
|   HTTP,HLS,   --push-+->- StreamCaster(4) -(rtmp)-+-> SRS          |
|   Device,            |                            |                |
|   ......)            |                            |                |
+----------------------+                            |                |
|  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 of SRS project:

A big THANK YOU goes to:

Mirrors

OSChina: https://gitee.com/winlinvip/srs.oschina, the GIT usage(CN, EN)

git clone https://gitee.com/winlinvip/srs.oschina.git srs &&
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/winlinvip/srs.oschina.git
3.0release 0m56.515s 95MB git clone -b 3.0release --depth=1 https://gitee.com/winlinvip/srs.oschina.git
develop 2m22.430s 234MB git clone -b develop https://gitee.com/winlinvip/srs.oschina.git
develop 0m46.421s 42MB git clone -b develop --depth=1 https://gitee.com/winlinvip/srs.oschina.git
min 2m22.865s 217MB git clone -b min https://gitee.com/winlinvip/srs.oschina.git
min 0m36.472s 11MB git clone -b min --depth=1 https://gitee.com/winlinvip/srs.oschina.git

System Requirements

Supported operating systems and hardware:

Beijing, 2013.10
Winlin