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,等待缓冲。。。。看到了什么?
如想了解更多技术架构文章,扫码关注我的个人公众号以及转发分享哈~