续接:https://javascript.net.cn/article?id=553
修改Nginx配置文件:
worker_processes 1;
error_log logs/error.log debug;
events {
worker_connections 1024;
}
rtmp {
server {
listen 1935;
application live {
live on;
}
application vod {
play D:/workspace/nginx/video; #这是一个目录的名称,如果是linux,则写具体位置如/opt/video
}
application mylive {
live on;
# record all;
# record_path D:/workspace/nginx/hls/record;
# record_max_size 200M;
hls on;
# 注意此地址设置,hls_path 代表 hls 目录及.m3u8文件的保存目录
hls_path D:/workspace/nginx/html/hls;
hls_fragment 1s;
hls_playlist_length 5;
allow play all;
}
}
}
http {
server {
listen 8000;
location / {
root html;
}
location /test.flv {
root video;
}
location /stat {
rtmp_stat all;
rtmp_stat_stylesheet stat.xsl;
}
location /stat.xsl {
root html;
}
location /hls {
# Serve HLS fragments
types {
application/vnd.apple.mpegurl m3u8;
video/mp2t ts;
text/html html;
}
# root html/hls;
alias html/hls;
add_header Cache-Control no-cache;
}
}
}
开启Nginx,然后本地开始向服务器推流:
ffmpeg -f avfoundation -framerate 30 -video_size 320x240 -i "0" -vcodec libx264 -acodec libfaac -f flv rtmp://116.196.19.33/mylive/test
服务器的hls目录就会开始生成ts文件,并不停的删除。
产生的相关地址:
推流地址: rtmp://服务器ip/mylive/xxxxx
播放地址: rtmp://服务器ip/mylive/xxxxx
hls地址: http://服务器ip:8000/hls/xxxxx.m3u8
状态查看地址: http://服务器ip:8000/stat
参考:
https://yq.aliyun.com/articles/626492
https://blog.yoodb.com/yoodb/article/detail/1470
声明:本站所有文章和图片,如无特殊说明,均为原创发布。商业转载请联系作者获得授权,非商业转载请注明出处。