网易网易视频云:用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;

Hostwinds:免费更换IP/优惠码美元VPS免费更换IP4.99,7月最新优惠码西雅图直连VPS

hostwinds怎么样?2021年7月最新 hostwinds 优惠码整理,Hostwinds 优惠套餐整理,Hostwinds 西雅图机房直连线路 VPS 推荐,目前最低仅需 $4.99 月付,并且可以免费更换 IP 地址。本文分享整理一下最新的 Hostwinds 优惠套餐,包括托管型 VPS、无托管型 VPS、Linux VPS、Windows VPS 等多种套餐。目前 Hostwinds...

弘速云香港VPSVPS线路有CN2+BGP、CN2 GIA,KVM虚拟化架构,裸金属月付564元

弘速云怎么样?弘速云是创建于2021年的品牌,运营该品牌的公司HOSU LIMITED(中文名称弘速科技有限公司)公司成立于2021年国内公司注册于2019年。HOSU LIMITED主要从事出售香港vps、美国VPS、香港独立服务器、香港站群服务器等,目前在售VPS线路有CN2+BGP、CN2 GIA,该公司旗下产品均采用KVM虚拟化架构。可联系商家代安装iso系统。点击进入:弘速云官方网站地址...

CloudCone闪购优惠洛杉矶MC机房VPS月$1.99 便宜可随意删除重开

CloudCone商家我们很多喜欢低价便宜VPS主机的肯定是熟悉的,个人不是特别喜欢他。因为我之前测试过几次,开通的机器IP都是不通的,需要删除且开通好几次才能得到一个可用的IP地址。当然他们家的优势也是有的,就是价格确实便宜,而且还支持删除重新开通,而且机房只有一个洛杉矶MC。实话,如果他们家能多几个机房,保持现在的特点,还是有很多市场的。CloudCone是来自美国的主机销售商,成立于2017...

网易服务器为你推荐
思科route设置mediacss3圆角在HTML里如何实现圆角矩形?windows键是哪个Windows快捷键是什么ipadwifiipad wifi信号差怎么办tcpip上的netbiostcpip上的netbios是什么用的,有安全隐患吗?开启还是关上ms17-010win1038度古贝春珍藏10价格?联通版iphone4s怎么知道到苹果4s是联通版,还是移动版迅雷下载速度迅雷下载速度真是太慢了杀毒软件免费下载2013排行榜杀毒软件排行榜2015有哪些?
厦门域名注册 dns是什么 堪萨斯服务器 yardvps 美国主机代购 英文简历模板word 铁通流量查询 howfile 柚子舍官网 网站cdn加速 域名接入 免费mysql数据库 云营销系统 阿里云手机官网 广州服务器托管 网站防护 香港ip 美国asp空间 德国代理ip 火山互联 更多