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

麻花云:3折优惠,香港CN2安徽麻花云香港安徽移动BGP云服务器(大带宽)

麻花云在7月特意为主机测评用户群定制了促销活动:香港宽频CN2云服务器、安徽移动云服务器(BGP网络,非单线,效果更好)、安徽移动独立服务器、安徽电信独立服务器,全部不限制流量,自带一个IPv4,默认5Gbps的DDoS防御。活动链接:https://www.mhyun.net/act/zjcp特价云服务器不限流量,自带一个IPv4,5Gbps防御香港宽频CN2全固态Ⅲ型 4核4G【KVM】内存:...

宝塔面板企业版和专业版618年中活动 永久授权仅1888元+

我们一般的站长或者企业服务器配置WEB环境会用到免费版本的宝塔面板。但是如果我们需要较多的付费插件扩展,或者是有需要企业功能应用的,短期来说我们可能选择按件按月付费的比较好,但是如果我们长期使用的话,有些网友认为选择宝塔面板企业版或者专业版是比较划算的。这样在年中大促618的时候,我们也可以看到宝塔面板也有发布促销活动。企业版年付899元,专业版永久授权1888元起步。对于有需要的网友来说,还是值...

易探云香港vps主机价格多少钱?香港云服务器主机租用价格

易探云香港vps主机价格多少钱?香港vps主机租用费用大体上是由配置决定的,我们选择香港vps主机租用最大的优势是免备案vps。但是,每家服务商的机房、配置、定价也不同。我们以最基础配置为标准,综合比对各大香港vps主机供应商的价格,即可选到高性能、价格适中的香港vps主机。通常1核CPU、1G内存、2Mbps独享带宽,价格在30元-120元/月。不过,易探云香港vps主机推出四个机房的优惠活动,...

网易服务器为你推荐
路由routegeneratedgoogle经营策略iphone支持ipad支持ipad城乡居民社会养老保险人脸识别生存认证photoshop技术PS技术是干什么的,如何使用PS技术?勒索病毒win7补丁怎么删除 防勒索病毒 打的补丁x-router思科路由器有线端无法上网,而无线段却可以,用的是PPPOE拨号上网,一开始两种方法都不可以,检查宽fusionchartsfusioncharts怎么生成图片至excel
联通vps 域名解析服务器 中国万网域名 免费动态域名 bbr 鲨鱼机 mediafire下载 idc评测网 godaddy域名转出 创宇云 qq数据库 刀片式服务器 免费吧 免费活动 最好的qq空间 ebay注册 谷歌台湾 阿里云邮箱登陆 免费个人网页 阿里dns 更多