这是一篇入门基础教程,还有其他的SRS搭建,RTSP协议,他们的区别和搭建方式,感兴趣或者从事这方面工作的,就自己去研究了。
1:安装Nginx
教程:https://blog.csdn.net/Brave_heart4pzj/article/details/108556564
2:安装nginx-rtmp-module模块
参考: https://blog.csdn.net/O0mm0O/article/details/73896384 (1)
https://blog.tomhuang2000.com/archives/572/ (2)
教程(1)比较好,可能发生的错误都给补充上了
以上两步操作完成后,就可以使用这个直播流服务器了
3、使用方法
工具:OBS studio录屏推流、potplayer拉流播放器
视频教程:
Nginx+RTMP 服务器搭建教程:https://www.bilibili.com/video/av78957794
OBS录屏推流教程:https://www.bilibili.com/video/av78808759
补充注意点:
1、OBS推流时候:下面三个地方的配置要对应好,串流秘钥随意,但是它觉定你后面的访问路径
2、potplayer使用时填写的播放地址
这里的yuchen111就是OBS里面配置的串流秘钥名称对应上
3、搭建过程中,所需相关软件下载地址
链接:https://pan.baidu.com/s/1v8E3BB-Ibtn4srLa1BQuwA
提取码:u5l8
补充:
可用Nginx配置:
#user nobody;
worker_processes 1;
error_log logs/error.log;
error_log logs/error.log notice;
error_log logs/error.log info;
#pid logs/nginx.pid;
events {
worker_connections 1024;
}
rtmp {
server {
listen 1935;
chunk_size 4000;
# TV mode: one publisher, many subscribers
application mylive {
# enable live streaming
live on;
# record first 200M of stream
record all;
record_path /opt/rtmp/live_record;
record_max_size 200M;
hls on;
hls_path /opt/rtmp/hls;
hls_fragment 1s;
hls_playlist_length 500;
allow play all;
#on_publish 'http://when start publish live call this url';
#on_done 'http://when live stop call this url';
}
}
}
http {
server {
listen 8080;
# This URL provides RTMP statistics in XML
location /stat {
rtmp_stat all;
# Use this stylesheet to view XML as web page
# in browser
rtmp_stat_stylesheet stat.xsl;
}
location /stat.xsl {
# XML stylesheet to view RTMP stats.
# Copy stat.xsl wherever you want
# and put the full directory path here
root /usr/local/nginx/html/;
}
location /hls {
# Serve HLS fragments
types {
application/vnd.apple.mpegurl m3u8;
video/mp2t ts;
}
root /opt/rtmp;
add_header Cache-Control no-cache;
}
}
}
你学废了吗?