网易网易视频云:用Nginx搭建flv,mp4,hls流媒体服务器

网易服务器  时间:2021-04-15  阅读:()

网易视频云用Nginx搭建flv,mp4,hls流媒体服务器

网易视频云是网易倾力打造的一款基于云计算的分布式多媒体处理集群和专业音视频技术提供稳定流畅、低时延、高并发的视频直播、录制、存储、转码及点播等音视频的PAAS服务在线教育、远程医疗、娱乐秀场、在线金融等各行业及企业用户只需经过简单的开发即可打造在线音视频平台。今天网易视频云就给大家分享关于用Nginx搭建flv,mp4,hls流媒体服务器的技术干货

模块:nginx_mod_h264_streaming 支持h264编码MP4格式的视频

模块:http_flv_module 支持flv

模块:http_mp4_module 支持mp4

模块: nginx-rtmp-module 支持rtmp协议也支持HLS

 1 模块下载和解压wget http://nginx.org/download/nginx-1 .6.0.tar.gzwg e thttp://h264.code-shop.com/download/nginx_mod_h264_streaming-2.2.7.tar.gzwget http://sourceforge.net/projects/pcre/fi les/pcre/8.35/pcre-8.35.tar.gzwget http://zl ib.net/zl ib-1 .2.8.tar.gz

wget http://www.openssl .org/source/openssl-1 .0. 1g.tar.gzwget -O nginx-rtmp-module.ziphttps://github.com/arut/nginx-rtmp-module/archive/master.zipunzip nginx-rtmp-module.ziptar -zxvf nginx-1 .6.0.tar.gztar -zxvf nginx_mod_h264_streaming-2.2.7.tar.gztar -zxvf pcre-8.35.tar.gztar -zxvf zl ib-1 .2.8.tar.gztar -zxvf openssl-1 .0.1g.tar.gz

 2 配置命令会生成makefile文件

./configure\

--prefix=/usr/local/nginx\

--add-module=. ./nginx_mod_h264_streaming-2.2.7\--add-module=. ./nginx-rtmp-module\

--with-http_flv_module\

--with-http_mp4_module\

--with-http_stub_status_module\

--with-http_ssl_module\

--with-pcre=. ./pcre-8.35\

--with-zl ib=. ./zl ib-1 .2.8\

--with-debug

 3 编译和安装ma kemake instal l

 4问题解决

【1 】 如果在configure过程中出现以下错误

/root/nginx_mod_h264_streaming-2.2.7/src/ngx_http_streaming_module.c: Infunction ‘ngx_streaming_handler’ :

/root/nginx_mod_h264_streaming-2.2.7/src/ngx_http_streaming_module.c: 158:error: ‘ngx_http_request_t’ has no membernamed ‘zero_in_uri ’make[1 ]: *** [objs/addon/src/ngx_http_h264_streaming_module.o]Error 1make[1 ]: Leaving directory`/root/nginx-0.8.54'make: *** [bui ld]Error 2

那么将src/ngx_http_streaming_module.c文件中以下代码删除或者是注释掉就可以了 

/*TODO:Win32*/if (r->zero_in_uri)

{return NGX_DECLINED;

}

如果你没有对这个文件做个更改那么应该在源码的第157-161行。这个问题是由于版本原因引起在此不再讨论。

修改完之后记得先执行make clean 然后再进行重新执行configure、 ma ke 最后make instal l。

【2】 如果在编译过程中出现以下错误cc1 :warnings being treated as errors

那么修改/nginx-1 .6.0/objs/Makefi le文件

CFLAGS= -pipe -O-W-Wal l -Wpointer-arith -Wno-unused-parameter-Werror -g -D_LARGEFILE_SOURCE-DBUILDING_NGINX

-I . ./nginx-rtmp-module-master

把上面的-Werror去掉不把warn ning当作error处理

 5Nginx的配置

#user nobody;worker_processes 1 ;

#error_log logs/error. log;

#error_log logs/error. log notice;

#error_log logs/error. log info;

#pid logs/nginx.pid;events{worker_connections 1024;

}rtmp{server {l isten 1935;chunk_size4000;

#video on demand forflvfi lesappl ication vod {play/usr/local/nginx/html/flv;

}

#video on demand for mp4 fi les

appl ication vod2{play/usr/local/nginx/html/mp4;

}appl ication hls{l ive on;hlson;hls_path /tmp/hls;

}

#MPEG-DASHissimi lar toHLSappl ication dash{l ive on;dashon;dash_path /tmp/dash;

}

}

}http{include mime.types;

default_type appl ication/octet-stream;

#log_format main '$remote_addr -$remote_user [$time_local] "$request" '# '$status$body_bytes_sent "$http_referer" '

# '"$http_user_agent" "$http_x_forwarded_for"' ;

#access_log logs/access. log main;sendfi le on;

#tcp_nopush on;

#keepal ive_timeout 0;keepal ive_timeout 65;

#gzip on;server {

#in case we have anotherweb server on port 80l isten 8080;server_name localhost;

#charset koi8-r;

#access_log logs/host.access. log main;location/ {root html ;

index index.html index.htm;

}

#error_page 404 /404.html ;

#redirect server error pages to the static page/50x.html#error_page 500502503504 /50x.html ;location =/50x.html {root html ;

}location~\.mp4${mp4;

}location~\.flv${flv;

}

#This URL provides RTMP statistics in XMLlocation/stat {rtmp_stat al l ;

rtmp_stat_stylesheet stat.xsl ;

}location/stat.xsl {

#XML stylesheet to view RTMP stats.#Copy stat.xsl wherever you want

#and put the ful l directory path herer o o t /va r/www/;

}location/hls{

#Serve HLS fragmentstypes{appl ication/vnd.apple.mpegurl m3u8;video/mp2t ts;

}

#where the m3u8 andtsfi les areal ias/usr/local/nginx/html/hls;

#l ive streaming setting

#root /tmp;

HTTPS加密协议端口默认是多少且是否支持更换端口访问

看到群里网友们在讨论由于不清楚的原因,有同学的网站无法访问。他的网站是没有用HTTPS的,直接访问他的HTTP是无法访问的,通过PING测试可以看到解析地址已经比较乱,应该是所谓的DNS污染。其中有网友提到采用HTTPS加密证书试试。因为HTTP和HTTPS走的不是一个端口,之前有网友这样测试过是可以缓解这样的问题。这样通过将网站绑定设置HTTPS之后,是可以打开的,看来网站的80端口出现问题,而...

TmhHost暑假活动:高端线路VPS季付8折优惠,可选洛杉矶CN2 GIA/日本软银/香港三网CN2 GIA/韩国双向CN2等

tmhhost怎么样?tmhhost正在搞暑假大促销活动,全部是高端线路VPS,现在直接季付8折优惠,活动截止时间是8月31日。可选机房及线路有美国洛杉矶cn2 gia+200G高防、洛杉矶三网CN2 GIA、洛杉矶CERA机房CN2 GIA,日本软银(100M带宽)、香港BGP直连200M带宽、香港三网CN2 GIA、韩国双向CN2。点击进入:tmhhost官方网站地址tmhhost优惠码:Tm...

CloudCone,美国洛杉矶独立服务器特价优惠,美国洛杉矶MC机房,100Mbps带宽不限流量,可选G口,E3-1270 v2处理器32G内存1Gbps带宽,69美元/月

今天CloudCone发布了最新的消息,推送了几款特价独立服务器/杜甫产品,美国洛杉矶MC机房,分配100Mbps带宽不限流量,可以选择G口限制流量计划方案,存储分配的比较大,选择HDD硬盘的话2TB起,MC机房到大陆地区线路还不错,有需要美国特价独立服务器的朋友可以关注一下。CloudCone怎么样?CloudCone服务器好不好?CloudCone值不值得购买?CloudCone是一家成立于2...

网易服务器为你推荐
contentcss日照职业技术学院RIZHAODeviceios5重庆宽带测速重庆电信测速我的网速溢出win10445端口win7系统不能被telnet端口号,端口、服务什么全都开了如何用itunes备份如何使用iTunes最新版进行备份?急!!联通合约机iphone5想咨询一下联通iphone5合约机和裸机的区别?苹果5.1完美越狱iphone 5.1版本怎么越狱?chrome18CHROME现在最新版是多少?ios8.1.3ios8.1.3、8.2、8.3,哪个版本最稳定
wordpress主机 香港vps99idc 美国翻墙 国内永久免费云服务器 win8.1企业版升级win10 bgp双线 seednet qq对话框 美国堪萨斯 国外免费asp空间 网游服务器 web服务器安全 浙江服务器 徐州电信 测速电信 汤博乐 镇江高防服务器 windowsserver2012r2 windowsserverr2 webmin 更多