1在http模块上面添加:
rtmp{ server{ listen 1935; chunk_size 5000; application hls{ live on; #开启实时直播 hls on; record off; #不记录数据 hls_path /application/nginx/html/hls; hls_fragment 15s; #设置15秒延时 } } } http { include mime.types; default_type application/octet-stream;
2在server模块里面配置:
server { listen 80; server_name localhost; #charset koi8-r; #access_log logs/host.access.log main; location / { root html; index index.html index.htm; } location /hls { #sever hls fragments types{ application/vnd.apple.mpegurl m3u8; video/mp2t ts; } alias /temp/hls; expires -1; }
3下载OBS软件安装并进行如下设置
https://cdn-fastly.obsproject.com/downloads/OBS-Studio-27.1.1-Full-Installer-x64.exe
添加音频输入和视频输入并进行如下设置:
服务:自定义
服务器:rtmp://10.0.0.61:1935
串流密钥:laiyue_live
4将播放器的html源码文件命名为play.html上传至服务器,并将源码中的视频直播源地址换成http://10.0.0.61/hls/laiyue_live.m3u8
5打开网址进行播放http://10.0.0.61/play.html