#Simple-RTMP-Server
下载发布版(github):
[Centos6-x86_64](http://winlinvip.github.io/srs.release/releases/files/SRS-CentOS6-x86_64-0.9.55.zip)
其他[more...](http://winlinvip.github.io/srs.release/releases/)
下载发布版(国内阿里云镜像):
[Centos6-x86_64](http://demo.chnvideo.com:8085/srs/releases/files/SRS-CentOS6-x86_64-0.9.55.zip)
其他[more...](http://demo.chnvideo.com:8085/srs/releases/)
加入QQ群: [http://url.cn/WAHICw](http://url.cn/WAHICw) (Group: 212189142)
获得源码(github): [https://github.com/winlinvip/simple-rtmp-server](https://github.com/winlinvip/simple-rtmp-server)
```bash
git clone https://github.com/winlinvip/simple-rtmp-server.git
```
获得源码(国内CSDN镜像): [https://code.csdn.net/winlinvip/srs-csdn](https://code.csdn.net/winlinvip/srs-csdn)
```bash
git clone https://code.csdn.net/winlinvip/srs-csdn.git
```
报告问题(BugReport): [https://github.com/winlinvip/simple-rtmp-server/issues/new](https://github.com/winlinvip/simple-rtmp-server/issues/new)
中文资料(Wiki): [https://github.com/winlinvip/simple-rtmp-server/wiki](https://github.com/winlinvip/simple-rtmp-server/wiki)
使用步骤(Usage): [https://github.com/winlinvip/simple-rtmp-server#usage](#usage)
功能摘要(Summary): [https://github.com/winlinvip/simple-rtmp-server#summary](#summary)
关于SRS(About): [https://github.com/winlinvip/simple-rtmp-server#about](#about)
作者信息(Authors): [https://github.com/winlinvip/simple-rtmp-server#authors](#authors)
更新历史(History): [https://github.com/winlinvip/simple-rtmp-server#history](#history)
性能报告(Performance): [https://github.com/winlinvip/simple-rtmp-server#performance](#performance)
发行分支(Releases): [https://github.com/winlinvip/simple-rtmp-server#releases](#releases)
横向对比(Compare): [https://github.com/winlinvip/simple-rtmp-server#compare](#compare)
关键架构(Architecture): [https://github.com/winlinvip/simple-rtmp-server#architecture](#architecture)
## About
SRS(SIMPLE RTMP Server) over state-threads created in 2013.10.
SRS is a simple, [RTMP](https://github.com/winlinvip/simple-rtmp-server/wiki/DeliveryRTMP)/[HLS](https://github.com/winlinvip/simple-rtmp-server/wiki/DeliveryHLS),
[high-performance](https://github.com/winlinvip/simple-rtmp-server/wiki/Performance), single/multiple(plan) processes, edge/origin live server,
[x86/x64/arm](https://github.com/winlinvip/simple-rtmp-server/wiki/SrsLinuxArm),
compile depends on [st](http://sourceforge.net/projects/state-threads)(required), [ssl](http://www.openssl.org/) and [http-parser](https://github.com/joyent/http-parser),
use [nginx](http://nginx.org/), [ffmpeg](http://ffmpeg.org/) and [cherrypy](http://www.cherrypy.org/) as external tools. that is, only need st to run srs for
minimum run. see [Build](https://github.com/winlinvip/simple-rtmp-server/wiki/Build).
SRS supports [vhost](https://github.com/winlinvip/simple-rtmp-server/wiki/RtmpUrlVhost),
rtmp([encoder push](https://github.com/winlinvip/simple-rtmp-server/wiki/DeliveryRTMP), client/[edge](https://github.com/winlinvip/simple-rtmp-server/wiki/Edge) pull), [ingester(srs pull)](https://github.com/winlinvip/simple-rtmp-server/wiki/Ingest),
[HLS](https://github.com/winlinvip/simple-rtmp-server/wiki/DeliveryHLS), [HLS audio only](https://github.com/winlinvip/simple-rtmp-server/wiki/DeliveryHLS#hlsaudioonly), [transcoding](https://github.com/winlinvip/simple-rtmp-server/wiki/FFMPEG),
[forward](https://github.com/winlinvip/simple-rtmp-server/wiki/FFMPEG), [http hooks](https://github.com/winlinvip/simple-rtmp-server/wiki/HTTPCallback), [http api](https://github.com/winlinvip/simple-rtmp-server/wiki/HTTPApi),
[http server](https://github.com/winlinvip/simple-rtmp-server/wiki/HTTPServer), [dvr](https://github.com/winlinvip/simple-rtmp-server/wiki/DVR), [FlashP2P](https://github.com/winlinvip/simple-rtmp-server/wiki/FlashP2P).
注意:FlashP2P系统为[chnvideo.com](http://www.chnvideo.com)商业方案,SRS只是支持对接。
Release: [http://winlinvip.github.io/simple-rtmp-server](http://winlinvip.github.io/simple-rtmp-server)
Blog: [http://blog.csdn.net/win_lin](http://blog.csdn.net/win_lin)
CSDN mirror: [https://code.csdn.net/winlinvip/srs-csdn](https://code.csdn.net/winlinvip/srs-csdn)
See also: [https://github.com/winlinvip/simple-rtmp-server](https://github.com/winlinvip/simple-rtmp-server)
Github DEMO: [demo with your SRS](http://winlinvip.github.io/simple-rtmp-server/trunk/research/players/srs_player.html?server=192.168.1.170&vhost=192.168.1.170)
Wiki: [https://github.com/winlinvip/simple-rtmp-server/wiki](https://github.com/winlinvip/simple-rtmp-server/wiki)
TencentQQ: [http://url.cn/WAHICw](http://url.cn/WAHICw) (Group: 212189142)
## AUTHORS
The PRIMARY AUTHORS are (and/or have been)(Authors ordered by first contribution):
* winlin([winterserver](#)): [http://blog.csdn.net/win_lin](http://blog.csdn.net/win_lin)
* wenjie([wenjiegit](https://github.com/wenjiegit/simple-rtmp-server)): [http://blog.chinaunix.net/uid/25006789.html](http://blog.chinaunix.net/uid/25006789.html)
About the primary AUTHORS:
* Contribute important features to SRS.
* Names of all PRIMARY AUTHORS response in NetConnection.connect and metadata.
* Names of all CONTRIBUTORS response in api/v1/authors.
And here is an inevitably incomplete list of MUCH-APPRECIATED CONTRIBUTORS --
people who have submitted patches, reported bugs, added translations, helped
answer newbie questions, and generally made SRS that much better: [AUTHORS.txt](https://github.com/winlinvip/simple-rtmp-server/blob/master/AUTHORS.txt)
A big THANK YOU goes to:
* [chnvideo](chnvideo.com) co-founders([wiseyoung](mailto:wiseyoung@chnvideo.com), [trueice](mailto:trueice@chnvideo.com), [leijian](mailto:leijian@chnvideo.com)) for [big supports](https://github.com/winlinvip/simple-rtmp-server/wiki/Product#bigthanks).
* Genes amd Mabbott for creating [st](https://github.com/winlinvip/state-threads)([state-threads](http://sourceforge.net/projects/state-threads/)).
* Michael Talyanksy for introducing us to use st.
* Roman Arutyunyan for creating [nginx-rtmp](https://github.com/arut/nginx-rtmp-module) for SRS to refer to.
* Joyent for creating [http-parser](https://github.com/joyent/http-parser) for http-api for SRS.
* Igor Sysoev for creating [nginx](http://nginx.org/) for SRS to refer to.
* [FFMPEG](http://ffmpeg.org/) and [libx264](http://www.videolan.org/) group for SRS to use to transcode.
* Guido van Rossum for creating Python for api-server for SRS.
## Usage
Step 1: get SRS
git clone https://github.com/winlinvip/simple-rtmp-server && cd simple-rtmp-server/trunkStep 2: build SRS, Requires Centos6.x/Ubuntu12 32/64bits, others see [Build](https://github.com/winlinvip/simple-rtmp-server/wiki/Build)
./configure && makeStep 3: start SRS
./objs/srs -c conf/srs.confSee also: * [Usage: How to delivery RTMP?](https://github.com/winlinvip/simple-rtmp-server/wiki/SampleRTMP) * [Usage: How to delivery HLS?](https://github.com/winlinvip/simple-rtmp-server/wiki/SampleHLS) * [Usage: How to delivery HLS for other codec?](https://github.com/winlinvip/simple-rtmp-server/wiki/SampleTranscode2HLS) * [Usage: How to transode RTMP stream by SRS?](https://github.com/winlinvip/simple-rtmp-server/wiki/SampleFFMPEG) * [Usage: How to forward stream to other server?](https://github.com/winlinvip/simple-rtmp-server/wiki/SampleForward) * [Usage: How to deploy low lantency application?](https://github.com/winlinvip/simple-rtmp-server/wiki/SampleRealtime) * [Usage: How to deploy SRS on ARM?](https://github.com/winlinvip/simple-rtmp-server/wiki/SampleARM) * [Usage: How to ingest file/stream/device to SRS?](https://github.com/winlinvip/simple-rtmp-server/wiki/SampleIngest) * [Usage: How to use SRS-HTTP-server to delivery HTTP/HLS stream?](https://github.com/winlinvip/simple-rtmp-server/wiki/SampleHTTP) * [Usage: How to show the demo of SRS?](https://github.com/winlinvip/simple-rtmp-server/wiki/SampleDemo) * [Usage: Solution using SRS?](https://github.com/winlinvip/simple-rtmp-server/wiki/Sample) * [Usage: Why SRS?](https://github.com/winlinvip/simple-rtmp-server/wiki/Product) ## System Requirements Supported operating systems and hardware: * All Linux , both 32 and 64 bits * All hardware. ## Summary 1. Simple: also stable enough. 1. [High-performance](https://github.com/winlinvip/simple-rtmp-server/wiki/Performance): single-thread, async socket, event/st-thread driven. 1. Support RTMP [edge](https://github.com/winlinvip/simple-rtmp-server/wiki/Edge) server, support origin server. 1. RTMP without vod streaming, live streaming only. 1. Support multiple processes, support single process. 1. Support vhost, support \_\_defaultVhost\_\_. 1. Support adobe rtmp live streaming. 1. Support apple [HLS(m3u8)](https://github.com/winlinvip/simple-rtmp-server/wiki/DeliveryHLS) live streaming. 1. Support HLS audio-only live streaming. 1. Support reload config to enable changes. 1. Support cache last gop for flash player to fast startup. 1. Support listen at multiple ports. 1. Support long time(>4.6hours) publish/play. 1. High performace, 1800 connections(500kbps), 900Mbps, CPU 90.2%, 41MB 1. Support forward publish stream to build active-standby [cluster](https://github.com/winlinvip/simple-rtmp-server/wiki/Cluster). 1. Support broadcast by forward the stream to other servers(origin/edge). 1. Support live stream transcoding by ffmpeg. 1. Support live stream forward(acopy/vcopy) by ffmpeg. 1. Support ffmpeg filters(logo/overlay/crop), x264 params, copy/vn/an. 1. Support audio transcode only, speex/mp3 to aac 1. Support [http callback api hooks](https://github.com/winlinvip/simple-rtmp-server/wiki/HTTPCallback)(for authentication and injection). 1. Support bandwidth test api and flash client. 1. Player, publisher(encoder), and demo pages(jquery+bootstrap). 1. Demo video meeting or chat(SRS+cherrypy+jquery+bootstrap). 1. Full documents in wiki, in chineses. 1. Support RTMP(play-publish) library: srs-librtmp 1. Support ARM([debian armhf, v7cpu](https://github.com/winlinvip/simple-rtmp-server/wiki/SrsLinuxArm)) with rtmp/ssl/hls/librtmp. 1. Support [init.d](https://github.com/winlinvip/simple-rtmp-server/wiki/LinuxService) and packge script, log to file. 1. Support RTMP ATC for HLS/HDS to support backup(failover) 1. Support http RESTful management api. 1. Support embeded http server for hls(live/vod) 1. Support stream ingester using ffmpeg. 1. Support ingest RTSP(RTP, SDP) stream to RTMP. 1. Support dvr(record live to flv file for vod) 1. Support live flashP2P(integrated by chnvideo VDN). 1. [dev] Support RTMP [edge](https://github.com/winlinvip/simple-rtmp-server/wiki/Edge) server, push/pull stream from any RTMP server 1. [plan] Support file to hls vod stream. 1. [plan] Support system full utest on gtest. 1. [plan] Support multiple processes, for both origin and edge 1. [no-plan] Support adobe RTMFP(flash p2p) protocol. 1. [no-plan] Support adobe flash refer/token/swf verification. 1. [no-plan] Support adobe amf3 codec. 1. [no-plan] Support encryption: RTMPE/RTMPS, HLS DRM 1. [no-plan] Support RTMPT, http to tranverse firewalls 1. [no-plan] Support file source, transcoding file to live stream 1. [no-plan] Support RTP/RTSP server. ## Releases * 2014-04-07, [Release v1.0-mainline](https://github.com/winlinvip/simple-rtmp-server/releases/tag/1.0.mainline), support [arm](https://github.com/winlinvip/simple-rtmp-server/wiki/SrsLinuxArm), [init.d](https://github.com/winlinvip/simple-rtmp-server/wiki/LinuxService), http [server](https://github.com/winlinvip/simple-rtmp-server/wiki/HTTPServer)/[api](https://github.com/winlinvip/simple-rtmp-server/wiki/HTTPApi), [ingest](https://github.com/winlinvip/simple-rtmp-server/wiki/SampleIngest). 30000 lines.
[winlin@dev6 srs]$ dstat ----total-cpu-usage---- -dsk/total- ---net/lo-- ---paging-- ---system-- usr sys idl wai hiq siq| read writ| recv send| in out | int csw 58 9 32 0 0 1| 0 4168k| 277M 277M| 0 0 | 29k 25k 61 8 30 0 0 1| 0 1168k| 336M 336M| 0 0 | 29k 24k 63 8 27 0 0 1| 0 2240k| 124M 124M| 0 0 | 32k 33k 62 8 28 0 0 1| 0 1632k| 110M 110M| 0 0 | 31k 33k 53 7 40 0 0 1| 0 1360k| 115M 115M| 0 0 | 24k 26k 51 7 41 0 0 1| 0 1184k| 146M 146M| 0 0 | 24k 27k 39 6 54 0 0 1| 0 1284k| 105M 105M| 0 0 | 22k 28k 41 6 52 0 0 1| 0 1264k| 116M 116M| 0 0 | 25k 28k 48 6 45 0 0 1| 0 1272k| 143M 143M| 0 0 | 27k 27k* See also: [Performance for x86/x64 Test Guide](https://github.com/winlinvip/simple-rtmp-server/wiki/Performance) * See also: [Performance for RaspberryPi](https://github.com/winlinvip/simple-rtmp-server/wiki/RaspberryPi) ## Compare * SRS v1.0-mainline: 30000 lines. support arm, init.d scripts, http server and api, ingest.
+------------------------------------------------------+ | SRS(Simple RTMP Server) | +---------------+---------------+-----------+----------+ | API/hook | Transcoder | HLS | RTMP | | http-parser | FFMPEG/x264 | NGINX/ts | protocol | +---------------+---------------+-----------+----------+ | Network(state-threads) | +------------------------------------------------------+ | All Linux(RHEL,CentOS,Ubuntu,Fedora...) | +------------------------------------------------------+### Modularity Architecture
+------------------------------------------------------+ | Main(srs/bandwidth/librtmp) | +------------------------------------------------------+ | App(Server/Client application) | +------------------------------------------------------+ | RTMP(Protocol stack) | +------------------------------------------------------+ | Kernel(depends on Core, provides error/log) | +------------------------------------------------------+ | Core(depends only on system apis) | +------------------------------------------------------+### Stream Architecture
+---------+ +----------+ + Publish + + Deliver | +---|-----+ +----|-----+ +----------------------+-------------------------+----------------+ | Input | SRS(Simple RTMP Server) | Output | +----------------------+-------------------------+----------------+ | Encoder(1) | +-> RTMP protocol ----+-> Flash Player | | (FMLE,FFMPEG, -rtmp-+->-+-> HLS/NGINX --------+-> m3u8 player | | Flash,XSPLIT, | +-> Fowarder ---------+-> RTMP Server | | ......) | +-> Transcoder -------+-> RTMP Server | | | +-> DVR --------------+-> FILE | | | +-> BandwidthTest ----+-> Flash/StLoad | +----------------------+ | | | MediaSource(2) | | | | (RTSP,FILE, | | | | HTTP,HLS, ------+->-- Ingester ----(rtmp)-+-> SRS | | Device, | | | | ......) | | | +----------------------+-------------------------+----------------+ Remark: (1) Encoder: encoder must push RTMP stream to SRS server. (2) MediaSource: any media source, which can be ingest by ffmpeg. (3) Ingester: SRS will fork a process to run ffmpeg(or your application) to ingest any input to rtmp, push to SRS.### [HDS/HLS origin backup](https://github.com/winlinvip/simple-rtmp-server/wiki/RTMP-ATC)
+----------+ +----------+ +--ATC->-+ server +--ATC->-+ packager +-+ +---------+ +----------+ | RTMP +----------+ RTMP +----------+ | | Reverse | +-------+ | encoder +->-+ +->-+ Proxy +-->-+ CDN + +----------+ | +----------+ +----------+ | | (nginx) | +-------+ +--ATC->-+ server +--ATC->-+ packager +-+ +---------+ RTMP +----------+ RTMP +----------+### (plan) RTMP cluster(origin/edge) Architecture Remark: cluster over forward, see [Cluster](https://github.com/winlinvip/simple-rtmp-server/wiki/Cluster)
+---------+ +-----------------+ +-----------------------+ + Encoder +--+-->-+ SRS(RTMP Edge) +--->-+ (RTMP Origin) | +---------+ | +-----------------+ | SRS/FMS/NGINX-RTMP | | | Red5/HELIX/CRTMP | +-------------------------->-+ ...... | +-----------------------+ Schema#1: Any RTMP encoder push RTMP stream to RTMP (origin/edge)server, where SRS RTMP Edge server will forward stream to origin. +-------------+ +-----------------+ +--------------------+ | RTMP Origin +-->-+ SRS(RTMP Edge) +--+->-+ Client(RTMP/HLS) | +-------------+ +-----------------+ | | Flash/IOS/Android | | +--------------------+ | | +-----------------+ +->-+ SRS(RTMP Edge) + +-----------------+ Schema#2: SRS RTMP Edge server pull stream from origin (or upstream SRS RTMP Edge server), then delivery to Client.### (plan) SRS Multiple processes Architecture(design by wenjie)
+---------------+ +--------+ | upnode server | + client + +-------+-------+ +---+----+ -------------+------------network-------+--------- | | +--------+ +----+-----------+ +----+----------+ | master +--fork->-+ back source(1) +-->-pull-+ stream 1-N(2) + +---+----+ +----------------+ +-------+-------+ | | +-------------------------------------fork--->-----+ | +-------------+ +-------------------fork-->-+ http/vod(3) | +-------------+ Remark: (1) back source process: create by master process, get stream from upnode server if edge, create stream if origin, serve the stream process. (2) stream process: create by master process, get stream from back source process, serve the client. (3) the embeded mininum http server, also provides vod service. for http server, it provides http api, hls(live/vod) delivery. for vod server, it slice the file to hls(m3u8/ts). Remark: (a) This multiple processes architecture is design by wenjie, it's a very simple and powerful multiple process architecture, for the master no need to pass between stream process. (b) The CLI architecture is similar to this, instead, cli process will collect informations from all stream process, master process only send signals to child processes.### (plan) CLI Architecture
+---------+ +--+ stream1 +---------+ | +---------+ | +--------+ | +---------+ | +-------+ | master +--fork->-+--+ streamN +---amf0--+>--+ cli + +--------+ | +---------+ | +-------+ | +-------------+ | +--+ back source +-----+ +-------------+ Remark: (1) master listen the global api port, for example, 33330 (2) back source and stream processes listen at private api port, for example, 33331, 33332, 33333 (3) work processes(stream and back-source), report private api port to master global api port. (4) cli connect to master global api port, get all other private api ports (5) cli connect to each stream/back-source process to get api data, cli analysis and summary the data, return to user.### Live FlashP2P
+--DVR------>-(flv file) +----------+ +-----+ | | encoder +--RTMP-->-+ SRS +-->--+ +----------+ +-----+ | | +------------+ +---HTTP-->-+ P2P system + callback +------------+Remark: P2P system provides by [chnvideo.com](http://www.chnvideo.com) 注意:FlashP2P系统为[chnvideo.com](http://www.chnvideo.com)商业方案,SRS只是支持对接。 ### Bandwidth Test Workflow
+------------+ +----------+ | Client | | Server | +-----+------+ +-----+----+ | | | connect vhost-------------> | | <-----------result(success) | | | | <----------call(start play) | | result(playing)----------> | | <-------------data(playing) | | <-----------call(stop play) | | result(stopped)----------> | | | | <-------call(start publish) | | result(publishing)-------> | | data(publishing)---------> | | <--------call(stop publish) | | result(stopped)(1)-------> | | | | <--------------------report | | final(2)-----------------> | | <END> | @See: class SrsBandwidth comments.Beijing, 2013.10