概要说明
- nginx的nginx-rtmp-module模块支持直播推流,以下记录搭建过程及步骤
- Demo基于docker的linux环境运行
操作步骤
- 编译安装nginx
docker run --name debian -p1935:1935 -p8888:8888 -it debian /bin/bash
cd /root
mkdir download
mkdir nginx
cd download
apt-get update
apt-get install curl
apt-get install gcc
apt-get install libpcre3 libpcre3-dev
apt-get install openssl libssl-dev
apt-get install zlib1g zlib1g-dev
apt-get install lrzsz
apt-get install make
apt-get install procps
curl -o nginx-1.18.0.tar.gz http://nginx.org/download/nginx-1.18.0.tar.gz
curl -o nrm.tar.gz https://codeload.github.com/arut/nginx-rtmp-module/legacy.tar.gz/master
tar -zxvf nginx-1.18.0.tar.gz
tar -zxvf nrm.tar.gz
mv arut-nginx-rtmp-module-afd350e nginx-rtmp-module
cd nginx-1.18.0
./configure --with-debug --with-http_ssl_module --add-module=/root/download/nginx-rtmp-module --prefix=/root/nginx
make && make install
cd /root/nginx/sbin
./nginx -V
- 修改nginx配置文件[/root/nginx/conf/nginx.conf],配置rtmp
user root;
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
rtmp {
server {
listen 1935;
chunk_size 4096;
application live{
live on;
}
}
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
#tcp_nopush on;
#keepalive_timeout 0;
keepalive_timeout 65;
#gzip on;
server {
listen 8888;
server_name localhost;
#charset koi8-r;
#access_log logs/host.access.log main;
location / {
root html;
index index.html index.htm;
}
location /stat {
rtmp_stat all;
rtmp_stat_stylesheet stat.xsl;
}
location /stat.xsl {
# 地址路径
root /root/download/nginx-rtmp-module/;
}
#error_page 404 /404.html;
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
}
-
推流
使用obs工具推流,推流地址 rtmp://localhost/live
-
拉流观看
使用IINA工具拉流, 拉流地址:rtmp://localhost/live
-
推拉流监控
监控地址 http://localhost:8888/stat