1.安装依赖
apt-get install build-essential libpcre3 libpcre3-dev libssl-dev
2.建一个目录
mldir rtmp_nginx
3.源码下载
wget http://nginx.org/download/nginx-1.21.6.tar.gz
wget https://github.com/arut/nginx-rtmp-module/archive/master.zip
4.解压缩
tar -xf nginx-1.21.6.tar.gz
unzip master.zip
5.编译安装到指定位置
cd nginx-1.21.6/
./configure --prefix=你的位置 --with-http_ssl_module --add-module=../nginx-rtmp-module-master
make && make install
6.添加到环境变量
sudo vim /etc/profile.d/export_path.sh
添加:
#!/bin/bashexport PATH=$PATH:/你的位置/nginx/sbin/
sudo vim PATH=$PATH:/你的位置/nginx/sbin/
7.验证,如图成功
8.rtmp配置
vim /你的位置/nginx/conf/nginx.conf
rtmp {server {listen 1935;chunk_size 4096;application live {live on;record off;}}
}
9.启动、重启、停止
systemctl start nginx systemctl restart nginx systemctl stop nginx
10.验证
ffmpeg退流mp4,拉流测试
1.sudo ffmpeg -re -stream_loop -1 -i /home/ych/tools/拉流测试/test.mp4 -vcodec libx264 -preset veryfast -vprofile baseline -acodec aac -f flv rtmp://127.0.0.1:1935/live/test