crtmpserver搭建 linux

2. crtmpserver流媒体服务器的搭建(linux平台)
    
    它的编译与build环境要求先安装一些linux工具
2.1 cmake的安装
    下载最新的cmake(http://www.cmake.org/)。
  1. #tar -zxvf cmake-2.8.7.tar.gz
  2. #cd cmake-2.8.7
  3. #./bootstrap
  4. #gmake
  5. #make install
2.2 openssl的安装
    下载openssl-0.9.8版(crtmpserver暂只支持这个版本,我用的是openssl-0.9.8t。http://www.openssl.org/
  1. #tar -zxvf openssl-0.9.8t.tar.gz
  2. #cd openssl-0.9.8t
  3. #./Configure
  4. #make .
  5. #make install
2.3 crtmpserver的编译与安装
  1. #svn co --username anonymous --password "" https://svn.rtmpd.com/crtmpserver/branches/1.0 crtmpserver
  2. #cd crtmpserver
  3. #sh ./cleanup.sh
  4. #cd builders/cmake
  5. #cmake .
  6. #make
  7. #./crtmpserver/crtmpserver ./crtmpserver/crtmpserver.lua
   NOTE:
   A. 如果make成功,最后一行命令是以“./crtmpserver/crtmpserver.lua”为配置脚本启动“crtmpserver"服务。
   B. 最后一行命令的目录是在"builders/cmake"下。

2.4 测试流的接收与分发
    最后一行命令执行后,可以看到默认脚本配置下启动的服务和对应的端口。如“RTMP”协议对应的是“1935”端口。
    如下所示:
--- --------------- ----- ------------------------- -------------------------
|tcp|       0.0.0.0 |1935|       inboundRtmp   |            appselector|
--- --------------- ----- ------------------------- -------------------------
推送:    
     可以使用Adobe 的FMLE(Flash Media Live Encoder)给这个服务器推送rtmp流。成功后会有相应的log信息提示。
     也可以使用ffmpeg给这个服务器推送rtmp流。成功后会有相应的log信息提示。但是请注意,ffmpeg推送rtmp流给它一定要使用"librtmp"才能成功。使用ffmpeg自带的rtmp推送会导致失败。原因应该是ffmpeg自带的rtmp程序不完整,解析不了第二次握手时服务发送来的包信息。
观看:
     推送成功后,用户端就可以用flash播放器或能播放rtmp流的播放器(如http://flv-player.us/index_mdv.php)看你推送的节目啦。
    也可以使用像rtmpdump的软件将rtmp流录成文件。
  
3. 简单的配置修改
    有时服务器会对某些端口做限制,这时就需要自己指定端口,如"80"端口。这个需求可以通过修改它的配置脚本“crtmpserver/crtmpserver.lua”来实现。
     如要添加“80”端口的"rtmp"服务,可以给“crtmpserver/crtmpserver.lua”添加如下代码。(包含“port=80"的第一层大括号的代码是要添加的)
  1. default=true, 
  2. acceptors = 
  3. { 
  4.   { 
  5.     ip="0.0.0.0", 
  6.     port=80, 
  7.     protocol="inboundRtmp" 
  8.    }, 
  9.    { 
  10.      ip="0.0.0.0", 
  11.      port=1935, 
  12.      protocol="inboundRtmp" 
  13.    },
  14.    ...
  15.   }
  16. }

  重启服务就可以看到端口生效,就可以从“80“接收rtmp流啦。


looking for openssl headers - not found

    sudo apt-get install libssl-dev


sudo cmake .后出现如下提示: 
-- Check for working CXX compiler: CMAKE_CXX_COMPILER-NOTFOUND 
CMake Error: your CXX compiler: "CMAKE_CXX_COMPILER-NOTFOUND" was not found. Please set CMAKE_CXX_COMPILER to a valid compiler path or name. 
CMake Error: Internal CMake error, TryCompile configure of cmake failed 
-- Check for working CXX compiler: CMAKE_CXX_COMPILER-NOTFOUND -- broken 
CMake Error: The C++ compiler "CMAKE_CXX_COMPILER-NOTFOUND" is not able to compile a simple test program. 
It fails with the following output: 
CMake will not be able to correctly generate this project. 
CMake Error: your CXX compiler: "CMAKE_CXX_COMPILER-NOTFOUND" was not found. Please set CMAKE_CXX_COMPILER to a valid compiler path or name. 
-- Configuring done 

解决办法:
1. sudo apt-get install g++
2. cmake -D CMAKE_CXX_COMPILER="g++" cmake -D CMAKE_BUILD_TYPE=Release -D CMAKE_INSTALL_PREFIX:PATH="/usr/local"

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
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值