crtmpserver组网方案

A Powerful Live Streaming Setup
搭建强大的直播系统

Recently we had a project requiring live streaming setup, but wasn’t for sure what the load 
or client usage would be. The prerequisite was to be prepared for 1-1000 users watching the 
event live. Thus we developed this configuration to insure end users would have a good 
streaming experience. As we continue using this configuration, I’ll be sure to stop back 
and update any configuration changes…
最近,我们有项目要求搭建一套直播系统,但是不确定加载的内容和客户端将如何使用;
先决条件是要准备支持1-1000个用户可以观看这个直播;
因此,我们开发了这个配置来确保终端用户都能获得良好的观看体验;
如果持续使用这个配置,我们做一些更新支持;


Our idea was to stream the live event directly to a “master server” and then distribute it 
to a multitude of “Mirror Servers” in order to handle the load. We could use more or less 
Mirror Servers to accommodate the number of connections expected, and could also ramp up the 
servers if needed during the event. We are using cloud servers with a pre-saved image for the 
Mirror Servers to build from. We personally use Rackspace Cloud just because we’ve had very 
good experience with them and feel like their prices are very reasonable. They also allow us 
to save a server-image and pay pennies a month for its storage. We can then start up a server 
from that custom image in a matter of minutes, sometimes even seconds.
我们的目的是将直播事件发送到主服务器,
为了处理加载,将它分发到多个镜像服务器;
我们可以依据连接数的预计来增删镜像服务器;
也可以在直播事件中添加服务器;
我们使用云服务器在镜像服务器上预存储文件;
我们使用的是Rackspace 云, 因为它有很好的功能并且价格合理;可实现实时扩充;


In the scenario pictured above we are using Wirecast to encode on a computer and transmit the 
live feed to the master server. The master server is a very small cloud server that costs next 
to nothing to keep running all the time. (Approximately $15 a month) All unused ports are 
blocked off and Flash Media Live Encoder Authentication is activated to prevent hackers/morons 
from using the server for their own use. Public clients never actually connect to the master 
server, only mirror servers connect to the master server. Since the master server is always 
online, we know its IP address and can easily connect to it. It was important to us to be able 
to replicate servers on the fly from an image, and not have to change each one’s configuration 
or the master server configuration for the event. Each mirror server is configured to pull a RTMP 
stream from the master server, and then stream it to anyone who connects. When the mirror server 
boots up, it immediately starts running C++ RTMP server and the RTMP server immediately connects 
to the master and begins re-broadcasting the live feed.
在上图中,我们使用Wirecast将直播种子传输到主服务器;
主服务器是一个很小的云服务器,对于全天候运行的成本非常小; 
所有的未使用的端口都是阻塞的,并且FMLE有授权限制;
发布内容的客户端不会直接连到主服务器;只有镜像服务器连接主服务器中;
因为主服务器是一直在线的,我们知道它的IP地址所以很容易连接;
能将服务器配置复制到镜像服务器上去很重要,这样就不用去修改每个镜像服务器的配置;
每个镜像服务器配置成从主服务器上去拉流,然后分发给建立连接的客户;
当镜像服务器启动后,它将立即运行crtmpserver并且它马上连接主服务器开始提供直播服务;


Thanks to Andrei’s wonderful help. We compiled C++ RTMP server on the mirror servers with 
live streaming completely disabled, thus adding a second layer of protection to the 
configuration from people trying to utilize our servers for their own event.
我们在镜像服务器上编译了crtmpserver并完全禁用了直播流,
这样为别人未授权就使用我们的配置提供了第二层保护;


By using FlowPlayer, its cluster plugin, we are able to distribute the load of connections 
in a round robin configuration in order to insure no one mirror server is too overloaded.
通过使用FlowPlayer, 它的集群插件,我们可以对连接负载进行分配,
以保护镜像服务器不过载;


这个文档并没讲实际要如何用crtmpserver如何组网,
如果要组网的话首先得解决多服务器间的crtmpserver流如何传输;
然后就是服务器的通信实现控制;
如果没有什么更详细的文档,就只能自己开发啦!

第三卦:《屯卦》

 

屯:元,亨,利,贞;勿用有攸往,利建侯。

【白话】《屯卦》象征初生:元始,亨通,和谐,贞正。不要急于发展,首先要立君建国。

 

《象》曰:云雷屯,君子以经纶。

【白话】《象辞》说:《屯卦》的卦象是震(雷)下坎(水)上,为雷上有水之表象,水在上表示雨尚未落,故释为云。
云雷大作,是即将下雨的征兆,故《屯卦》象征初生。
这里表示天地初创,国家始建,正人君子应以全部才智投入到创建国家的事业中去。

C++ RTMP Server Instructions how to compile and use C++ RTMP Server (a.k.a crtmpserver) Requirements: * GCC and other C++ tools * SVN * libdl, libssl, libcrypto (make sure you have the "devel" packages of libdl, ssl and crypto installed prior to compiling) In order to get the source code, issue the following command: svn co --username anonymous https://svn.rtmpd.com/crtmpserver/trunk crtmpserver When it asks for password, hit Enter key Compile the package. Do the following steps: cd crtmpserver/builders/cmake cmake . (this step will create all the Makefile's that are required. If some package is missing, the cmake will complain) make The compilation procedure should be finished within few minutes. After you compiled the package, it's time to test it. Run the following command: ./crtmpserver/crtmpserver crtmpserver/crtmpserver.lua If everything goes well, you'll get on your console a table with IP's, ports, protocols, and application names If you see this table, then crtmpserver is working. Lets test it the server. Follow these simple steps: * Download a simple FLV or MP4 file. You can dowload a sample file from here: http://www.mediacollege.com/adobe/flash/video/tutorial/example-flv.html * Place the file you downloaded into the crtmpserver/media folder * Download an FLV player. For this example, we'll use JW Player. Get it here: http://www.longtailvideo.com/players/jw-flv-player * Extract the JW Player to a directory which is accessible through your web server * Go to the extracted directory and create an HTML file which will include the player and play the file. Here's an example: <html> <body> <script type='text/javascript' src='swfobject.js'></script> <div id='mediaspace'>This text will be replaced</div> <script type='text/javascript'> var so = new SWFObject('player.swf','mpl','640','360','9'); so.addParam('allowfullscreen','true'); so.addParam('allowscriptaccess','always'); so.addParam('wmode','opaque'); so.addVariable('file','file-download'); so.addVariable('streamer','rtmp://127.0.0.1/flvplayback/'); so.write('mediaspace'); </script> </body> </html> * Change the 127.0.0.1 to either the IP of your crtmpserver or simply use a hostname of your machine * Replace file-download with the actual filename of your sample you download. Remeber to omit the .flv if it's an FLV file * Open a web browser and point it to to the web server IP/Hostname and the directory you installed the player (example: http://127.0.0.1/player) * You should see a player. Click the play button and the video should be played. If you see the video, then everything works well. Installing crtmpserver: * Go to the directory crtmpserver/cmake * Run the following command: cmake -DCRTMPSERVER_INSTALL_PREFIX=<path> (for example /usr/local/crtmpserver) * After previous command done start build project with command: make * After build comlete run command: make install * After install you has installed crtmpserver in <path>(in our case /usr/local/crtmpserver) * Now you can start crtmpserver with command: sudo <path>/sbin/crtmpserver --uid=<UID> <path>/etc/crtmpserver.lua in our case: sudo /usr/local/crtmpserver/sbin/crtmpserver --uid=<UID> /usr/local/crtmpserver/etc/crtmpserver.lua Also look into builders/packing directory. There are several OS specific builders. * in directory "debian" builder for Debian, also can be used for Ubuntu and other distributions based on debian * in directory "freebsd" builder(port) for FreeBSD crtmpserver settings * All crtmpserver settings are located in a detailed file calle: crtmpserver.lua
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

北雨南萍

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值