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

Puaex:香港vds,wtt套餐,G口带宽不限流量;可解流媒体,限量补货

puaex怎么样?puaex是一家去年成立的国人商家,本站也分享过几次,他家主要销售香港商宽的套餐,给的全部为G口带宽,而且是不限流量的,目前有WTT和HKBN两种线路的方面,虽然商家的价格比较贵,但是每次补一些货,就会被抢空,之前一直都是断货的状态,目前商家进行了补货,有需要这种类型机器的朋友可以入手。点击进入:puaex商家官方网站Puaex香港vds套餐:全部为KVM虚拟架构,G口的带宽,可...

个人网站备案流程及注意事项(内容方向和适用主机商)

如今我们还有在做个人网站吗?随着自媒体和短视频的发展和兴起,包括我们很多WEB2.0产品的延续,当然也包括个人建站市场的低迷和用户关注的不同,有些个人已经不在做网站。但是,由于我们有些朋友出于网站的爱好或者说是有些项目还是基于PC端网站的,还是有网友抱有信心的,比如我们看到有一些老牌个人网站依旧在运行,且还有新网站的出现。今天在这篇文章中谈谈有网友问关于个人网站备案的问题。这个也是前几天有他在选择...

HostKvm:香港国际/韩国KVM夏季7折,2G内存套餐月付5.95美元起

HostKvm是一家成立于2013年的国外主机服务商,主要提供基于KVM架构的VPS主机,可选数据中心包括日本、新加坡、韩国、美国、中国香港等多个地区机房,均为国内直连或优化线路,延迟较低,适合建站或者远程办公等。目前商家发布了夏季特别促销活动,针对香港国际/韩国机房VPS主机提供7折优惠码,其他机房全场8折,优惠后2GB内存套餐月付5.95美元起。下面分别列出几款主机套餐配置信息。套餐:韩国KR...

网易服务器为你推荐
Specificationsapple搜狗高速浏览器columnios5win7关闭445端口win7系统怎么关闭445和135这两个端口127.0.0.1DNS老是被修改为127.0.0.1,这是为什么?tcpip上的netbios怎么启用TCP/IP上的NetBIOS重庆电信宽带管家电信的宽带上网助手是什么?win7关闭135端口win7系统怎么关闭135端口?网上很多方法都不好用!联通合约机iphone5联通合约机iphone5能用移动卡吗google搜图google的直接搜索图片的功能为什么没了
厦门虚拟主机 域名是什么 qq域名邮箱 淘宝抢红包攻略 国内免备案主机 美国翻墙 淘宝双十一2018 网页背景图片 申请个人网页 html空间 本网站服务器在美国 太原联通测速平台 阿里校园 phpmyadmin配置 空间首页登陆 网页提速 免费ftp 英雄联盟台服官网 广东服务器托管 锐速 更多