利用Nginx搭建http和rtmp协议的流媒体服务器

实验目的:让Nginx支持flv和mp4格式文件,同时支持Rtmp协议;同时打开rtmp的hls功能

 资料:
 HTTP Live Streaming(缩写是 HLS)是一个由苹果公司提出的基于HTTP的流媒体 网络传输协议。
 HLS只请求基本的HTTP报文,与实时传输协议(RTP)不同,HLS可以穿过任何允许HTTP数据通过的防火墙或者代理服务器。它也很容易使用内容分发网络来传输媒体流。
 使用ffmpeg来完成对flv、mp4、mp3等格式的转化(点播实验暂时不测试)
 
一、准备工作
 模块:nginx_mod_h264_streaming(支持h264编码的视频)
 模块:http_flv_module 支持flv
 模块:http_mp4_module 支持mp4
 下载地址:
 http://h264.code-shop.com/download/nginx_mod_h264_streaming-2.2.7.tar.gz
 http://nginx.org
 https://github.com/arut/nginx-rtmp-module
 
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_64 

2、安装git工具:
 #mkdir soft-source
 #cd soft-source
 #wget http://www.codemonkey.org.uk/projects/git-snapshots/git/git-latest.tar.gz
 #tar xzvf git-latest.tar.gz
#cd git-2013-02-04
 #autoconf
 #./configure
 #make && make install
 # git --version
 git version 1.8.1.GIT
 #cd ..
 
3、安装ffmpeg及其依赖包:
 ++++++++Yasm+++++++++++
 #wget http://www.tortall.net/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 ..
 ++++++++x264+++++++++++
 #git clone git://git.videolan.org/x264
 #cd x264
 #./configure --enable-shared
#make
 #make install
 #cd ..
 ++++++++LAME+++++++++++
 #wget http://downloads.sourceforge.net/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 ..
 ++++++++libogg+++++++++++
 #wget http://downloads.xiph.org/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 ..
 ++++++++libvorbis+++++++++++
 #wget http://downloads.xiph.org/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 ..
 ++++++++libvpx+++++++++++
 #git clone http://git.chromium.org/webm/libvpx.git
 #cd libvpx
 #./configure  --enable-shared
 #make
 #make install
 #cd ..
 ++++++++FAAD2+++++++++++
 #wget http://downloads.sourceforge.net/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 ..
 ++++++++FAAC+++++++++++
 #wget http://downloads.sourceforge.net/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 ..
 ++++++++Xvid+++++++++++
 #wget http://downloads.xvid.org/downloads/xvidcore-1.3.2.tar.gz
 #tar zxvf xvidcore-1.3.2.tar.gz
 #cd xvidcore/build/generic
 #./configure
 #make
 #make install
 cd ..
 #git clone git://source.ffmpeg.org/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

相关推荐