Ubuntu下安装、编译、运行crtmpserver

一、crtmpserver简介

  crtmpserver是一个由C++语言编写的开源的RTMP流媒体服务器。与Adobe公司的商业产品FMS相比,从功能上来说crtmpserver只有FMS的部分功能,与flash player的兼容性也比不上FMS。但如果公司没钱用不起商业的FMS,crtmpserver是一个比较好的替代选择。crtmpserver提供了最常见的RTMP实现。作为开源的高性能RTMP流媒体服务器,不仅可以用在x86平台的linux服务器,windows服务器,还可以被用在arm等嵌入式平台上。crtmpserver的代码结构良好,类的继承体系清楚,代码效率高。是学习RTMP协议和服务器端编程的好例子。以上是博主在其它地方摘抄的crtmpserver简介,下面介绍它在Ubuntu下的安装过程。

 

二、crtmpserver安装

打开Ubuntu(博主是在VMWare12中安装的Ubuntu14.04,64位),切换为root用户。安装crtmpserver之前首先得安装cmake和libssl-dev,并且如果我们很久没有update了,我们得update更新一下软件列表。在Ubuntu中执行命令:

apt-get update
apt-get install cmake
apt-get install libssl-dev

 

在浏览器中打开crtmpserver在GitHub中的地址https://github.com/j0sh/crtmpserver。点击下图中红色框里面的按钮“Clone or download”下载crtmpserver

 

下载完后我们可以在windows主机中得到crtmpserver-centosinit.zip这个压缩文件,如下图所示。我们通过共享文件夹等方式将其拷贝到虚拟机的Ubuntu中。

 

拷贝到Ubuntu后,我们在Ubuntu中执行命令解压crtmpserver-centosinit.zip。

unzip crtmpserver-centosinit.zip

 

解压后可以得到目录crtmpserver-centosinit,如下图所示:

 

执行命令:

cd crtmpserver-centosinit/builders/cmake
cmake . 
make

 

执行完上述命令后,我们会发现目录下有下面的文件:

 

执行命令:

./crtmpserver/crtmpserver ./crtmpserver/crtmpserver.lua

 

出现下图所示界面,则表示crtmpserver安装成功

 

三、推流测试

安装完成后,我们可以使用FFmpeg将视频推流到crtmpserver,通过vlc拉流播放进行测试。测试地址:https://blog.csdn.net/u014552102/article/details/86558931

  • 0
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
编译记录 : ~、 common 工程 缺少 utils/misc/format.cpp utils/logging/formatter.cpp ~、thelib 工程 增加宏定义 “HAS_MEDIA_TS” \crtmpsvr_tr\sources\thelib\src\mediaformats\readers 全部重新组织添加 \crtmpsvr_tr\sources\thelib\src\protocols\ts 去掉 " " 以及相应的头文件。 去掉 protocols 下的 " " 新建筛选器目录“protocols/passthrough”,添加此目录下的两个文件 (可选) \thelib\src\protocols\ts\basetsappprotocolhandler.cpp BaseTSAppProtocolHandler::BaseTSAppProtocolHandler(Variant &configuration) //红标处漏写 -chenlx : BaseAppProtocolHandler(configuration) { \sources\thelib\src\netio\select\tcpcarrier.cpp TCPCarrier::TCPCarrier(int32_t fd) : IOHandler(fd, fd, IOHT_TCP_CARRIER) { //EventLogger::GetDefaultLogger()->LogCarrierCreated(stats); //-chenlx 去掉 netio\select\inboundnamedpipecarrier.cpp .h 添加 \fdstats.cpp JsonVariantProtocol.cpp 新建筛选器目录并添加源文件: thelib\src\recording ~、卸载项目 applestreamingclient,取消crtmpserver对applestreamingclient库的依赖,原因 是trunk中根本就没用到这个项目,对比branches和trunk中的cmake文件,applestreamingclient工程明显被注释。 注意,要先取消crtmpserver对applestreamingclient库的依赖再卸载:在项目crtmpserver上右击属性,在框架和引用上将对applestreamingclient链接库依赖选择false ~、vm \sources\vm\src\basevmlua.cpp 编不过去,提示“luaL_Reg”类型非法 在 \sources\common\include\utils\lua\luautils.h 里引入下列头文件,并重新编译 common.lib extern "C" { #include <lualib.h> #include <lauxlib.h> } ~、 appselector 、 flvplayback :\lab\ztttprj\coder\_svr_voip\streaming_\crtmpsvr_tr\sources\applications\flvplayback\include\tsappprotocolhandler.h(30): error C2504: “BaseTSAppProtocolHandler”: 未定义基类 增加宏定义 “HAS_MEDIA_TS”
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
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值