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

青云互联19元/月,美国洛杉矶CN2GIA/香港安畅CN2云服务器低至;日本云主机

青云互联怎么样?青云互联美国洛杉矶cn2GIA云服务器低至19元/月起;香港安畅cn2云服务器低至19元/月起;日本cn2云主机低至35元/月起!青云互联是一家成立于2020年的主机服务商,致力于为用户提供高性价比稳定快速的主机托管服务。青云互联本站之前已经更新过很多相关文章介绍了,青云互联的机房有香港和洛杉矶,都有CN2 GIA线路、洛杉矶带高防,商家承诺试用7天,打死全额退款点击进入:青云互联...

轻云互联-618钜惠秒杀,香港CN2大宽带KVM架构云服务器月付22元,美国圣何塞精品云月付19元爆款!海量产品好货超值促销进行中!

官方网站:点击访问青云互联活动官网优惠码:终身88折扣优惠码:WN789-2021香港测试IP:154.196.254美国测试IP:243.164.1活动方案:用户购买任意全区域云服务器月付以上享受免费更换IP服务;限美国区域云服务器凡是购买均可以提交工单定制天机防火墙高防御保护端口以及保护模式;香港区域购买季度、半年付、年付周期均可免费申请额外1IP;使用优惠码购买后续费周期终身同活动价,价格不...

Pacificrack:新增三款超级秒杀套餐/洛杉矶QN机房/1Gbps月流量1TB/年付仅7美刀

PacificRack最近促销上瘾了,活动频繁,接二连三的追加便宜VPS秒杀,PacificRack在 7月中下旬已经推出了五款秒杀VPS套餐,现在商家又新增了三款更便宜的特价套餐,年付低至7.2美元,这已经是本月第三波促销,带宽都是1Gbps。PacificRack 7月秒杀VPS整个系列都是PR-M,也就是魔方的后台管理。2G内存起步的支持Windows 7、10、Server 2003\20...

网易服务器为你推荐
AppleTVapple巴尔扎克搜狗拼音输入法4宜昌市体育中心"中科院重庆绿色智能技术研究院采购供应商信息登记表"present37杭州市西湖区翠苑第四幼儿园智慧校园采购项目支持ipadnetbios端口netbios ssn是什么意思?canvas2Canvas ~セピア色のモチーフ~ 这个动画片的中文翻译是什么?从哪看?重庆电信宽带测速重庆电信光纤宽带网络,内外网络和电脑等设备都没发生变化的情况下,办理了从20M提速到100M业务。
申请域名 怎么注册域名 过期域名抢注 ix主机 linkcloud 京东云擎 淘宝双十一2018 ibrs e蜗牛 dd444 免空 微信收钱 新天域互联 电信主机 卡巴斯基免费试用版 申请免费空间和域名 移动服务器托管 空间登入 便宜空间 英国伦敦 更多