在线直播还是挺容易搭建的,入门很容易。
按段分成:推流------>转----->拉流
本次搭建的:
- OBS Studio对应到推流部分
- nginx+rtmp-module对应到转部分(ffmpeg推后再介绍)
- VLC对应拉流部分
先自行下载nginx以及rtmp包:
- http://nginx.org/download/nginx-1.18.0.tar.gz
- https://codeload.github.com/arut/nginx-rtmp-module/zip/master
搭建命令行:
[root@iZuf6e0il1e05m6rdx5sx4Z sbin]# history
1 ll
2 unzip
3 yum install unzip
4 unzip
5 ll
6 unzip nginx-1.18.0.tar.gz
7 ll
8 unzip nginx-rtmp-module-master.zip
9 ll
10 tar -xvzf nginx-1.18.0.tar.gz
11 ll
12 cd nginx-1.18.0
13 ll
14 ./configure --add-module=/root/nginx-rtmp-module-master
15 ./configure --add-module=/root/nginx-rtmp-module-master --prefix=/opt/nginx
16 make
17 make install
18 pwd
19 ll
20 pwd
21 cd /opt/nginx
22 ll
23 cd sbin/
24 ll
25 nginx
26 ./nginx
27 ./nginx -s reload
28 history
---------------------------------------------------------------------------
[root@iZuf6e0il1e05m6rdx5sx4Z conf]# cat nginx.conf
#user nobody;
worker_processes 1;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
server {
listen 80;
server_name localhost;
location / {
root html;
index index.html index.htm;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
}
rtmp {
server {
listen 1935;
chunk_size 4000;
# TV mode: one publisher, many subscribers
application mytv {
# enable live streaming
live on;
hls on;
hls_path /tmp/av;
hls_fragment 5s;
allow publish all;
}
}
}
用OBS Studio做录像以及推流工具,关键配置如下:

VLC拉流,关键配置如下:

搞定