|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
如果您觉得本篇CentOSLinux教程讲得好,请记得点击右边漂浮的分享程序,把好文章分享给你的好朋友们!<p>试验目标:让Nginx支撑flv和mp4格局文件,同时支撑Rtmp协定;同时翻开rtmp的hls功效
材料:
HTTPLiveStreaming(缩写是HLS)是一个由苹果公司提出的基于HTTP的流媒体收集传输协定。
HLS只要求根本的HTTP报文,与及时传输协定(RTP)分歧,HLS可以穿过任何许可HTTP数据经由过程的防火墙或许署理办事器。它也很轻易应用内容分发收集来传输媒体流。
应用ffmpeg来完成对flv、mp4、mp3等格局的转化(点播试验临时意外试)
1、预备任务
模块: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-yinstallgccglibcglibc-develmakenasmpkgconfiglib-developenssl-develexpat-develgettext-devellibtoolmhash.x86_64perl-Digest-SHA1.x86_64
2、装置git对象:
#mkdirsoft-source
#cdsoft-source
#wgethttp://www.codemonkey.org.uk/projects/git-snapshots/git/git-latest.tar.gz
#tarxzvfgit-latest.tar.gz
#cdgit-2013-02-04
#autoconf
#./configure
#make&&makeinstall
#git--version
gitversion1.8.1.GIT
#cd..
3、装置ffmpeg及其依附包:
++++++++Yasm+++++++++++
#wgethttp://www.ckuyun.com/projects/yasm/releases/yasm-1.2.0.tar.gz
#tarxzvfyasm-1.2.0.tar.gz
#cdyasm-1.2.0
#./configure
#make
#makeinstall
#cd..
++++++++x264+++++++++++
#gitclonegit://git.videolan.org/x264
#cdx264
#./configure--enable-shared
#make
#makeinstall
#cd..
++++++++LAME+++++++++++
#wgethttp://downloads.sourceforge.net/project/lame/lame/3.99/lame-3.99.5.tar.gz
#tarxzvflame-3.99.5.tar.gz
#cdlame-3.99.5
#./configure--enable-nasm
#make
#makeinstall
#cd..
++++++++libogg+++++++++++
#wgethttp://downloads.xiph.org/releases/ogg/libogg-1.3.0.tar.gz
#tarxzvflibogg-1.3.0.tar.gz
#cdlibogg-1.3.0
#./configure
#make
#makeinstall
#cd..
++++++++libvorbis+++++++++++
#wgethttp://downloads.xiph.org/releases/vorbis/libvorbis-1.3.3.tar.gz
#tarxzvflibvorbis-1.3.3.tar.gz
#cdlibvorbis-1.3.3
#./configure
#make
#makeinstall
#cd..
++++++++libvpx+++++++++++
#gitclonehttp://git.chromium.org/webm/libvpx.git
#cdlibvpx
#./configure--enable-shared
#make
#makeinstall
#cd..
++++++++FAAD2+++++++++++
#wgethttp://downloads.sourceforge.net/project/faac/faad2-src/faad2-2.7/faad2-2.7.tar.gz
#tarzxvffaad2-2.7.tar.gz
#cdfaad2-2.7
#./configure
#make
#makeinstall
#cd..
++++++++FAAC+++++++++++
#wgethttp://downloads.sourceforge.net/project/faac/faac-src/faac-1.28/faac-1.28.tar.gz
#tarzxvffaac-1.28.tar.gz
#cdfaac-1.28
#./configure
#make
#makeinstall
#cd..
++++++++Xvid+++++++++++
#wgethttp://downloads.xvid.org/downloads/xvidcore-1.3.2.tar.gz
#tarzxvfxvidcore-1.3.2.tar.gz
#cdxvidcore/build/generic
#./configure
#make
#makeinstall
cd..
#gitclonegit://source.ffmpeg.org/ffmpeg
#cdffmpeg
#./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&&makeinstall
#cd..
修正/etc/ld.so.conf以下:
includeld.so.conf.d/*.conf
/lib
/lib64
/usr/lib
/usr/lib64
/usr/local/lib
/usr/local/lib64
/opt/ffmpeg/lib
#ldconfig
2、装置Nginx相干模块
#tarzxvfnginx_mod_h264_streaming-2.2.7.tar.gz
#gitclonegit://github.com/arut/nginx-rtmp-module.git
#tarzxvfpcre-8.12.tar.gz
#cdpcre-8.12
#./configure
#make&&makeinstall
#tarzxvfnginx-1.2.6.tar.gz
#cdnginx-1.2.6
#./configure--prefix=/usr/local/nginx--add-module=../nginx_mod_h264_streaming-2.2.7--with-http_flv_module--with-http_gzip_static_module--with-http_stub_status_module--with-http_mp4_module--add-module=../nginx-rtmp-module--add-module=../nginx-rtmp-module/hls--with-cc-opt=-I/opt/ffmpeg/include--with-ld-opt=-L/opt/ffmpeg/lib-Wl,-rpath=/opt/ffmpeg/lib
#make&&makeinstall
3、修正nginx主设置装备摆设文件,设置装备摆设虚拟主机(这里我们临时只设置装备摆设和测试点播,直播请看自创地址):
usernobodynobody;
worker_processes4;
error_loglogs/nginx_error.loginfo;
pidlogs/nginx.pid;
worker_rlimit_nofile51200;
events
{
useepoll;
worker_connections51200;
}
#rtmp_auto_pushon;
rtmp{
server{
listen1935;
applicationvod{
play/opt/media/nginxrtmp/flv;
}
}
}
http
{
includemime.types;
default_typeapplication/octet-stream;
server_names_hash_bucket_size128;
client_header_buffer_size32k;
large_client_header_buffers432k;
client_max_body_size50m;
limit_conn_zone$binary_remote_addrzone=perip:256k;
limit_conn_log_levelnotice;
sendfileon;
tcp_nopushon;
keepalive_timeout6000;#测试并发暂时调年夜
tcp_nodelayon;
gzipon;
gzip_min_length1k;
gzip_buffers416k;
gzip_http_version1.0;
gzip_comp_level2;
gzip_typestext/plainapplication/x-javascripttext/CSSapplication/xml;
gzip_varyon;
#logformat
log_formatmain$remote_addr-$remote_user[$time_local]"$request"
$status$body_bytes_sent"$http_referer"
"$http_user_agent"$http_x_forwarded_for;
#支撑flv
server
{
listen8081;
server_name192.168.0.33;
root/opt/pub/media/nginx;#http协定时刻,flv视频地位
location~.*.(flv|swf|mp4|wma|wmv)${
valid_referersnoneblocked*.xxxx.comhttp://localhost;
if($invalid_referer){
return403;
}
}
location~.flv${ |
|