centos搭建rtmp流服务器
在centos系统,使用nginx搭建rtmp流服务器
#!/bin/bash
cd /usr/local/src
sudo yum install -y git make gcc gcc-c++ wget
sudo yum -y install pcre-devel openssl openssl-devel
sudo git clone https://github.com/arut/nginx-rtmp-module.git
sudo wget http://nginx.org/download/nginx-1.16.0.tar.gz
sudo tar -zxvf nginx-1.16.0.tar.gz
cd nginx-1.16.0
sudo ./configure --prefix=/usr/local/src/nginx --add-module=../nginx-rtmp-module --with-http_ssl_module
sudo make
sudo make install
cd /usr/local/src/nginx/
echo "
rtmp {
server {
listen 1935; #监听的端口
chunk_size 4000;
application cctvf {#rtmp推流请求路径 (切记路径错了会推不上流)
live on; #开启实时
hls on; #开启hls
hls_path /usr/local/src/nginx/html/cctvf; #rtmp推流请求路径,文件存放路径
hls_fragment 5s; #每个TS文件包含5秒的视频内容
}
}
}
" >> ./conf/nginx.conf
sudo ./sbin/nginx -c ./conf/nginx.conf
sudo cp ./sbin/nginx /usr/bin/
sudo mkdir /usr/local/src/nginx/html/
sudo mkdir /usr/local/src/nginx/html/cctvf