nginx + nginx-rtmp-module
tar -xzvf nginx-1.18.0.tar.gz
unzip nginx-rtmp-module-master.zip
./configure --add-module=/root/nginx/nginx-rtmp-module-master
make
make install
server {
listen 80;
server_name localhost;
#charset koi8-r;
#access_log logs/host.access.log main;
location / {
root html;
index index.html index.htm;
}
#配置RTMP状态一览HTTP页面=========================================
location /stat {
rtmp_stat all;
rtmp_stat_stylesheet stat.xsl;
}
location /stat.xsl {
root /opt/rtmp/nginx-rtmp-module/;
}
#配置RTMP状态一览界面结束==========================
#HTTP协议访问直播流文件配置
location /hls { #添加视频流存放地址。
types {
application/vnd.apple.mpegurl m3u8;
video/mp2t ts;
}
#访问权限开启,否则访问这个地址会报403
autoindex on;
alias /usr/local/nginx/html/hls;#视频流存放地址,与下面的hls_path相对应,这里root和alias的区别可自行百度
expires -1;
add_header Cache-Control no-cache;
#防止跨域问题
add_header 'Access-Control-Allow-Origin' '*';
add_header 'Access-Control-Allow-Credentials' 'true';
add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
add_header 'Access-Control-Allow-Headers' 'DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type';
}
}
ffmpeg -i test.mp4 -vcodec copy -acodec copy -vbsf h264_mp4toannexb t/test.ts
ffmpeg -i t/test.ts -c copy -map 0 -f segment -segment_list t/test.m3u8 -segment_time 3 t/test%04d.ts

浙公网安备 33010602011771号