Windows 7下用VS2013编译crtmpserver

这一篇博客堪称是Win7(Windows 7)下用VS2012(Visual Studio 2012)编译librtmp的姊妹篇,这两个库是进行rtmp开发的经典开源组合。

一.准备工作

1.下载crtmpserver源码crtmpserver-centosinit.rar

下载链接:https://github.com/j0sh/crtmpserver

2.下载并编译crtmpserver的依赖库openSSL

本文主要想说明如何编译crtmpserver,openSSL的编译过程略,只提供其已经编译好的头文件和静态库。


二.开始编译

1.解压crtmpserver-centosinit.rar到E盘,将openSSL的头文件和静态库文件拷贝到E:\crtmpserver-centosinit\3rdparty,如下图所示。


双击E:\crtmpserver-centosinit\builders\VS2010\VS2010.sln,这里虽然是VS2010.sln,却默认是由VS2013打开的。用记事本打开VS1010.sln,前两行如下图所示,说明确实关联到了VS2013。


那就用VS2013编译吧,反正也差不多。这个解决方案一共包含了13个项目,如下图所示。


将编译的选项设置为Release。

2.将openSSL的头文件和静态库文件添加到13个项目中,最好使用相对路径,这样的话项目换到其他目录也不影响编译。需要注意的是,相对路径是相对项目文件.vcxproj的。如下图所示。


libeay32.lib和ssleay32.lib已经被源码维护者添加到了链接器的附加依赖项,如下图所示,我们就不需要添加了。


3.在这13个项目中,common、lua和thelib是基础,crtmpserver是最后需要得到的项目,其他的若干项目是crtmpserver的示例应用。所以需要先编译common、lua和thelib,然后右键解决方案——>重新生成解决方案,幸运的是,编译过程中并无错误,最后在E:\crtmpserver-centosinit\builders\VS2010目录中生成Release文件夹。但是该Release文件夹中包含了一些编译生成的中间文件,双击E:\crtmpserver-centosinit\builders\VS2010目录下的release.bat,可以将这些中间文件删除,删除后的Release文件夹如下图所示。

参考链接http://lgy-047.blog.163.com/blog/static/61346565201481725134264/中提到编译会出现错误,可能因为他是用VS2010进行编译的。



三.启动服务器(重要)

打开命令提示符,进行如下图所示操作来启动服务器。


可是服务器并未启动,所以有网友反映编译成功了,但是启动未看到 go go go (http://ask.csdn.net/questions/72610)。这是因为服务器没有配置好,配置文件crtmpserver.lua是一个Lua脚本,可用为程序提供灵活的扩展和定制功能。

这里先对crtmpserver.lua做基本的配置,让服务器可用启动,更深入的配置等以后用到了再说。

1.在E:\crtmpserver-centosinit\builders\VS2010\Release中新建log和meida文件夹,将crtmpserver.lua中下图蓝色行改为fileName="./log/crtmpserver",,表示日志文件将以crtmpserver为前缀,存储在当前目录(crtmpserver.exe所在目录)的log文件夹中,“./”不要也行。


然后将下图蓝色行改为mediaFolder="./media",。


需要说明的是name="flvplayback",,表示服务器实例的名字,所有的实例都在E:\crtmpserver-centosinit\builders\VS2010\Release\applications目录中,里面的每个文件夹表示一个实例。

mediaFolder表示实例的内容存放的位置,可以任意指定。

“aliases”表示别名组,所以在推拉流时,rtmp地址中的用别名组中的任意一个别名,比如说“live”来代替实例名“flvplayback”,可以达到同样的效果

2.将下图所示部分注释掉,注释方法--[[......]]--,图中给出的是注释后的结果。


其他的配置默认,再次通过命令提示符启动服务,虽然还是失败,但是有提示出现了,如下图所示。


根据提示可以看出,应该是9999端口被占用了,回到crtmpserver.lua,将下图蓝色行的端口改成其他数字,比如说8888。当然,这个错误并不是每个人都会遇到,因为这个端口可能没被占用。


再次通过命令提示符启动服务,这次终于启动成功了,出现了久违的go go go,如下图所示。


关闭服务很简单,Ctrl+C即可,再次启动还是执行指令crtmpserver.exe crtmpserver.lua


四.测试

1.找个.flv格式的视频放在E:\crtmpserver-centosinit\builders\VS2010\Release\media目录中,这里用的是sample.flv。

2.启动服务器。

3.启动VLC播放器,我用的版本是vlc-2.2.4,其他版本为测试。

选择菜单“媒体”——>“流”,在弹出的窗口中选择“网络”标签,如下图所示。


输入图中所示的URL地址,然后点击“串流”按钮,弹出下图所示窗口。


点击“下一步”按钮,弹出下图所示窗口。


勾选“在本地显示”,点击“下一步”按钮,弹出下图所示窗口。


不勾选“激活转码”,这里不需要转码,然后点击“下一步”按钮,弹出下图所示窗口。


点击“流”按钮,开始播放服务器中的sample.flv,如下图所示。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
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、付费专栏及课程。

余额充值