1、下载nginx并解压
地址:http://nginx-win.ecsds.eu/download/
本篇文章百度云盘链接中中也有提供压缩包
2、下载rtmp模块与nginx.exe放在同一目录
地址:https://github.com/arut/nginx-rtmp-module
本篇文章百度云盘链接中中也有提供压缩包
3、新建配置文件conf/nginx.conf
worker_processes 2;
rtmp{
server {
listen 1935;
chunk_size 4096;
application hls {
live on;
hls on;
hls_path tmp/hls;
hls_fragment 1s;
hls_cleanup on;
hls_continuous on;
hls_playlist_length 3s;
hls_nested on;
}
}
}
http{
server {
listen 81;
server_name localhost;
#access_log logs/host.access.log main;
location / {
root html;
index index.html index.htm;
add_header Access-Control-Allow-Origin *;
add_header Access-Control-Allow-Headers "Origin, X-Requested-With, Content-Type, Accept";
add_header Access-Control-Allow-Methods "GET, POST, OPTIONS";
}
location /control {
rtmp_control all;
}
location /hls {
# Serve HLS fragments
types {
application/vnd.apple.mpegurl m3u8;
video/mp2t ts;
}
alias tmp/hls;
expires -1;
add_header Cache-Control no-cache;
add_header Access-Control-Allow-Origin *;
add_header Access-Control-Allow-Headers "Origin, X-Requested-With, Content-Type, Accept";
add_header Access-Control-Allow-Methods "GET, POST, OPTIONS";
}
location /stat {
rtmp_stat all;
rtmp_stat_stylesheet stat.xsl;
}
location /stat.xsl {
root nginx-rtmp-module/;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
}
4、将相应端口81、1935开放
请在本站搜索windows系统开放端口号相关的文章
5、开启服务(cmd在nginx目录下)
nginx.exe -c conf\nginx.conf
6、关闭服务可直接杀进程
7、注:如果视频切片存放文件目录无法生成,手动建立tmp/hls 文件目录
8、OBS推流
1、点击设置->直播
服务器:IP地址改为本地服务器ip,串流密码随意设置,如111
2、开启直播
9、使用VLC视频播放器接收视频流
媒体–打开网络串流—