29 Jan 2021
想试试用nginx搞直播
现在一般用rtmp推流,用http-flv或者hls播放
set -e yum install gcc gcc-c++ cmake -y groupadd nginx useradd -g nginx nginx yum install pcre-devel openssl openssl-devel zlib-devel -y git clone https://github.com/winshining/nginx-http-flv-module.git # 下载nginx # cd 到nginx源码目录 ./configure --user=nginx --group=nginx \ --prefix=/usr/local/nginx \ --with-http_ssl_module \ --with-pcre \ --with-http_realip_module \ --with-http_v2_module \ --add-module=/usr/local/src/nginx-http-flv-module make make install
nginx.conf
# 要单核
worker_processes 1;
http {
...
server {
listen 80;
location /hls {
types {
application/vnd.apple.mpegurl m3u8;
video/mp2t ts;
}
root /data/nginx/stream;
add_header 'Cache-Control' 'no-cache';
}
}
}
rtmp {
server {
listen 1985;
chunk_size 4000;
application myapp {
live on;
hls on;
hls_path /data/nginx/stream/hls;
}
}
}
参考文件:去查rtmp和flv的github,那边说明很详细