当前位置:文档之家› 课题_nginx搭建rtmp协议流媒体服务器总结

课题_nginx搭建rtmp协议流媒体服务器总结

nginx搭建rtmp协议流媒体服务器总结最近在ubuntu12.04上搭建了一个rtmp服务器,感觉还挺麻烦的,所以记录下。

大部分都是参考网络上的资料。

前提:在linux下某个目录中新建一个nginx目录。

然后进入该目录去下载搭建环境所需要的一些资源包。

此处在/root/ 目录下新建一个nginx目录即:/root/nginx/====================================1、安装依赖包:#yum -y install gcc glibc glibc-devel make nasm pkgconfig lib-devel openssl-devel expat-devel gettext-devel libtool mhash.x86_64 perl-Digest-SHA1.x86_642、安装相关工具包1). git# mkdir soft-source# cd soft-source# wget :///projects/git-snapshots/git/git-latest.tar.xz# xz -d git-latest.tar.xz# tar xzvf git-latest.tar# cd git-2014-06-27# autoconf# ./configure# make && make install# git --versiongit version 2.0.0.GIT# cd ..2). zlib# wget :///zlib-1.2.8.tar.gz# tar -zxvf zlib-1.2.8.tar.gz cd zlib-1.2.8# ./configure# make# make install# cd ..3). pcre# wget ://exim.mirror.fr/pcre/pcre-8.12.tar.gz# tar zxvf pcre-8.12.tar.gz# cd pcre-8.12# ./configure# make && make install# cd ..4). yadmiyadmi的作用是为flv文件添加关键帧,才能实现拖动播放# wget :///projects/yamdi/files/yamdi/1.4/yamdi-1.4.tar.gz/download# tar xzvf download# cd yamdi-1.4# make && make install# cd ..使用方法:# yamdi -i input.flv -o out.flv给input.flv文件添加关键帧,输出为out.flv文件5). OpenSSL# wget :///source/openssl-1.0.1c.tar.gz# tar -zxvf openssl-1.0.1c.tar.gz# ./config# make# make install3、安装ffmpeg及其依赖包:1). Yasm# wget :///projects/yasm/releases/yasm-1.2.0.tar.gz# tar xzvf yasm-1.2.0.tar.gz# cd yasm-1.2.0# ./configure# make# make install# cd ..2). x264# git clone git:///x264# cd x264# ./configure --enable-shared# make# make install# cd ..3). LAME# wget :///project/lame/lame/3.99/lame-3.99.5.tar.gz# tar xzvf lame-3.99.5.tar.gz# cd lame-3.99.5#./configure --enable-nasm# make# make install# cd ..4). libogg# wget :///releases/ogg/libogg-1.3.0.tar.gz# tar xzvf libogg-1.3.0.tar.gz# cd libogg-1.3.0# ./configure# make# make install# cd ..5). libvorbis# wget :///releases/vorbis/libvorbis-1.3.3.tar.gz# tar xzvf libvorbis-1.3.3.tar.gz# cd libvorbis-1.3.3# ./configure# make# make install# cd ..6). libvpx# git clone :///webm/libvpx.git# cd libvpx# ./configure --enable-shared# make# make install# cd ..7). FAAD2# wget :///project/faac/faad2-src/faad2-2.7/faad2-2.7.tar.gz # tar zxvf faad2-2.7.tar.gz# cd faad2-2.7# ./configure# make# make install# cd ..8). FAAC# wget :///project/faac/faac-src/faac-1.28/faac-1.28.tar.gz # tar zxvf faac-1.28.tar.gz# cd faac-1.28# ./configure# make# make install# cd ..注:编译时可能遇到一下错误:mpeg4ip.h:126: error: new declaration ‘char* strcasestr(const char*, const char*)’解决方法:从123行开始修改此文件mpeg4ip.h,到129行结束。

修改前:#ifdef __cplusplusextern "C" {#endifchar *strcasestr(const char *haystack, const char *needle);#ifdef __cplusplus}#endif修改后:#ifdef __cplusplusextern "C++" {#endifconst char *strcasestr(const char *haystack, const char *needle);#ifdef __cplusplus}#endif9). Xvid# wget :///downloads/xvidcore-1.3.2.tar.gz# tar zxvf xvidcore-1.3.2.tar.gz# cd xvidcore/build/generic# ./configure# make# make install# cd ..10). ffmpeg# git clone git:///ffmpeg# cd ffmpeg# ./configure --prefix=/opt/ffmpeg/ --enable-version3--enable-libvpx --enable-libfaac --enable-libmp3lame--enable-libvorbis --enable-libx264 --enable-libxvid--enable-shared --enable-gpl --enable-postproc --enable-nonfree--enable-avfilter --enable-pthreads# make && make install# cd ..修改/etc/ld.so.conf如下:include ld.so.conf.d/*.conf/lib/lib64/usr/lib/usr/lib64/usr/local/lib/usr/local/lib64/opt/ffmpeg/lib# ldconfig二、安装Nginx相关模块1. 模块安装# wget :///download/nginx_mod_h264_streaming-2.2.7.tar.gz # tar zxvf nginx_mod_h264_streaming-2.2.7.tar.gz# git clone git:///arut/nginx-rtmp-module.git2. 创建用户和组# groupadd# useradd -g3. nginx安装# wget :///download/nginx-1.6.0.tar.gz# tar zxvf nginx-1.6.0.tar.gz# cd nginx-1.6.04.编译安装nginx在nginx-1.6.0目录下新建文件:nginx_configure.sh然后使用gedit 打开进行编辑:#!/bin/shecho "configure start ..."./configure \--prefix=/usr/local/nginx \--sbin-path=/usr/local/nginx/nginx \--conf-path=/usr/local/nginx/nginx.conf \--pid-path=/usr/local/nginx/nginx.pid \--error-log-path=/usr/local/nginx/logs/error.log \--add-module=../nginx_mod_h264_streaming-2.2.7 \--with-pcre=../pcre-8.12 \--with-zlib=../zlib-1.2.8 \--with-_dav_module \--with-_flv_module \--with-_stub_status_module \--without-_scgi_module \--without-_uwsgi_module \--without-_gzip_module \--without-_ssi_module \--without-_proxy_module \--without-_memcached_module \--without-_empty_gif_module \--without-mail_pop3_module \--without-mail_imap_module \--without-mail_smtp_module \--with-_ssl_module \--with-openssl=../openssl-1.0.1c \--add-module=../nginx-rtmp-module \--with-cc-opt=-I/opt/ffmpeg/include \--with-ld-opt=`-L/opt/ffmpeg/lib -Wl, -rpath=/opt/ffmpeg/lib`echo "configure end!"【保存并退出】# chmod +x nginx_configure.sh# ./nginx_configure.sh# make# make install备注:在执行make的时候可能出现错误1:adding module in ../nginx_mod_h264_streaming-2.2.7+ ngx__h264_streaming_module was configuredadding module in ../nginx-rtmp-module+ ngx_rtmp_module was configuredchecking for OpenSSL library ... not found./configure: error: SSL modules require the OpenSSL library.You can either do not enable the modules, or install the OpenSSL libraryinto the system, or build the OpenSSL library statically from the sourcewith nginx by using --with-openssl=<path> option.configure end!root@ubuntu:/home/song/nginx-t/nginx-1.6.0# makemake: *** No rule to make target `build', needed by `default'. Stop.解决方法:a)可以安装sslapt-get install opensslapt-get install libssl-devb)也可以添加--with-openssl=<path>在执行make的时候可能出现错误2:/root/nginx_mod_h264_streaming-2.2.7/src/ngx__streaming_module.c: In function ‘ngx_streaming_handler’:/root/nginx_mod_h264_streaming-2.2.7/src/ngx__streaming_module.c:158: error: ‘ngx__request_t’ has no member named ‘zero_in_uri’make[1]: *** [objs/addon/src/ngx__h264_streaming_module.o] Error 1make[1]: Leaving directory `/root/nginx-0.8.54'make: *** [build] Error 2解决方法:那么将src/ngx__streaming_module.c文件中以下代码删除或者是注释掉就可以了:/* TODO: Win32 */if (r->zero_in_uri){return NGX_DECLINED;}在执行make的时候可能出现错误3:../nginx_mod_h264_streaming-2.2.7/src/mp4_reader.c: 在函数‘esds_read’中:../nginx_mod_h264_streaming-2.2.7/src/mp4_reader.c:377:16: 错误:变量‘stream_priority’被设定但未被使用[-Werror=unused-but-set-variable] ../nginx_mod_h264_streaming-2.2.7/src/mp4_reader.c:376:12: 错误:变量‘stream_id’被设定但未被使用[-Werror=unused-but-set-variable]../nginx_mod_h264_streaming-2.2.7/src/mp4_reader.c: 在函数‘stsd_parse_vide’中:../nginx_mod_h264_streaming-2.2.7/src/mp4_reader.c:529:22: 错误:变量‘level_indication’被设定但未被使用[-Werror=unused-but-set-variable] ../nginx_mod_h264_streaming-2.2.7/src/mp4_reader.c:528:22: 错误:变量‘profile_compatibility’被设定但未被使用[-Werror=unused-but-set-variable] ../nginx_mod_h264_streaming-2.2.7/src/mp4_reader.c:527:22: 错误:变量‘profile_indication’被设定但未被使用[-Werror=unused-but-set-variable] ../nginx_mod_h264_streaming-2.2.7/src/mp4_reader.c:526:22: 错误:变量‘configuration_version’被设定但未被使用[-Werror=unused-but-set-variable] cc1: all warnings being treated as errorsmake[1]: *** [objs/addon/src/mp4_reader.o] 错误1解决方法:# vim objs/Makefile (修改objs/Makefile文件, 去掉其中的"-Werror"), 然后就能够正常编译了.然后在make就能过了。

相关主题