搭建视频直播服务_nginx+rtmp模块

 

 


1、下载安装
wget http://nginx.org/download/nginx-1.9.15.tar.gz


wget https://github.com/arut/nginx-rtmp-module/archive/master.zip


tar -zxvf nginx-1.9.15.tar.gz
unzip master.zip
cd nginx-1.9.15


./configure --with-http_ssl_module --add-module=../nginx-rtmp-module-master
make && make install

 

 

 

 


2、修改配置文件,vi /usr/local/nginx/conf/nginx.conf
2.1、添加,在http{}后添加
rtmp {
server {
listen 1935;
chunk_size 4096;
application live {
live on;
record off;
}
application live2 {
live on;
record off;
}
application hls {
live on;
hls on;
hls_path /tmp/hls;
}
}
}


2.2、修改http{}
http {
    server {
listen      88;
# This URL provides RTMP statistics in XML
location /stat {
   rtmp_stat all;
   # Use this stylesheet to view XML as web page
   # in browser
   rtmp_stat_stylesheet stat.xsl;
}
location /stat.xsl {
   # XML stylesheet to view RTMP stats.
   # Copy stat.xsl wherever you want
   # and put the full directory path here
   root /path/to/stat.xsl/;
}
location /hls {
   # Serve HLS fragments
   types {
application/vnd.apple.mpegurl m3u8;
video/mp2t ts;
   }
   root /tmp;
   add_header Cache-Control no-cache;
}
location /dash {
   # Serve DASH fragments
   root /tmp;
   add_header Cache-Control no-cache;
}
    }
}


3、启动nginx,/usr/local/nginx/sbin/nginx


4、直播测试
Windows下,下载obs,打开obs-设定-广播设定-FMS URL-rtmp://XXX.XXX.XXX.XXX:1935/live


5、播放测试

 

 

window下或者mac下,下载vld播放器,file-open network-rtmp://XXX.XXX.XXX.XXX:1935/live,等待缓冲。。。。看到了什么?

 

 

 

如想了解更多技术架构文章,扫码关注我的个人公众号以及转发分享哈~

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值