RTMP全程Real Time Protocal(实时小时传输协议)。
该协议基于TCP,是一个协议族,包括RTMP基本协议及RTMPT/RTMPS、RTMPE等多种变种协议。
RTMP是是一种设计用来进行实时数据通信的网络协议,主要用来在Flash/AIR平台和支持RTMP协议的流媒体/交互服务器之间进行音视频和数据通信
可以使用以下命令在 Ubuntu 系统中安装以上依赖项:
sudo apt-get update
sudo apt-get install build-essential libpcre3-dev zlib1g-dev libssl-dev
nginx可以用开源的nginx-rtmp-module模块简单提供RTMP服务。
链接:https://github.com/arut/nginx-rtmp-module nginx管理:https://nginx.org/en/download.html
使用下面命令将代码clone到本地
git clone https://github.com/arut/nginx-rtmp-module
wget https://nginx.org/download/nginx-1.26.3.tar.gz
tar -zxvf nginx-1.26.3.tar.gz
进入 nginx目录、执行下面命令
./configure \
--with-threads \
--with-http_stub_status_module \
--with-http_ssl_module \
--with-http_realip_module \
--with-stream \
--with-stream_ssl_module \
--add-module=../nginx-rtmp-module
编译
make
安装
make install
将 Nginx 可执行文件连接到系统 PATH 中的目录:
sudo ln -s /usr/local/nginx/sbin/nginx /usr/local/bin/nginx
Nginx 的配置文件默认位于 /usr/local/nginx/conf/nginx.conf,将下面的配置示例添加到文件末尾即可
nano /usr/local/nginx/conf/nginx.conf
rtmp {
server { # 标识为一个服务
listen 1935 # rtmp流服务器监听的端口号
so_keepalive=2s:1:2; #
chunk_size 4000; # 流复用块的大小,值越大cpu消耗越低
application live { # live是推拉流的路径名字
live on; # 开始实时直播
}
}
}
#验证
nginx -t
#应用
nginx -s reload
服务器地址组成如:rtmp://ip:port/path/secretkey
ip:rtmp流服务器安装的linux系统的IP,这里我用的是阿里云主机,所以填写了阿里云主机的公网IP,你根据 自己的情况填写。 port:rtmp流服务监听的端口号,我们已经配置为8890. path:live推流路径,我们已经配置为live secretkey很简单,自己填写一段数字就可以,这里我填写123.

评论