nginx-rtmp-module是基于nginx开发的一个实现rtmp流媒体服务器,而在其中也实现了对hls协议的支持。nginx-rtmp-module下载地址:https://github.com/arut/nginx-rtmp-module 。这里这里主要是对nginx.conf配置文件做介绍
events {
worker_connections 300000;
use epoll;
}
rtmp_auto_push on;
rtmp {
server {
listen 1935;
application live {
live on;
}
application hls {
live on;
hls on;
hls_path /tmp/hls;
hls_fragment 5s;
}
}
}
...
http {
...
server {
listen 8080;
location /stat {
rtmp_stat all;
rtmp_stat_stylesheet stat.xsl;
}
location /stat.xsl {
root /home/wangc/software/nginx-rtmp-module-master/;
}
location /control {
rtmp_control all;
}
location /rtmp-publisher {
root /home/wangc/software/nginx-rtmp-module-master/test;
}
location /hls {
types {
application/vnd.apple.mpegurl m3u8;
video/mp2t ts;
}
root /tmp;
add_header Cache-Control no-cache;
}
}
...
}
这样配置好了之后,就可以发布视频,然后看下直播效果。
比如:发布流为rtmp://192.168.1.2/hls/livestream,请求流则为http://192.168.1.2:8080/hls/livestream.m3u8。