用nginx-rtmp-module搭建rtmp流媒体服务器

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/dz_hexiang/article/details/79257733
前言

利用开源的nginx-rtmp-moduleNginx搭建流媒体服务器。Nginx是一个非常出色的http服务器,nginx-rtmp-module是一个开源的Nginx扩展模块,拥有很多功能特性,像接收rtmp推流拉流,hls直播等:

1.RTMP/HLS/MPEG-DASH live streaming
2.RTMP Video on demand FLV/MP4, playing from local filesystem or HTTP
3.Stream relay support for distributed streaming: push & pull models
4.Recording streams in multiple FLVs
5.H264/AAC support
6.Online transcoding with FFmpeg
7.HTTP callbacks (publish/play/record/update etc)
8.Running external programs on certain events (exec)
9.HTTP control module for recording audio/video and dropping clients
10.Advanced buffering techniques to keep memory allocations at a minimum level for faster streaming and low memory footprint
11.Proved to work with Wirecast, FMS, Wowza, JWPlayer, FlowPlayer, StrobeMediaPlayback, ffmpeg, avconv, rtmpdump, flvstreamer and many more
12.Statistics in XML/XSL in machine- & human- readable form
13.Linux/FreeBSD/MacOS/Windows

下面是配置安装使用详细过程
1.下载nginx

nginx官方下载地址:https://nginx.org/en/download.html

wget https://nginx.org/download/nginx-1.13.8.tar.gz
2.解压
tar -zxvf nginx-1.13.8.tar.gz
3.下载nginx的扩展模块 nginx-rtmp-module

用于接收rtmp 推流,搭建流媒体服务器
源码地址:https://github.com/arut/nginx-rtmp-module

git clone https://github.com/arut/nginx-rtmp-module
4.安装些必要的插件库
 apt-get install libpcre3 libpcre3-dev -y
 apt-get install libssl-dev -y
5.配置安装 nginx-rtmp-module

进入nginx源码,配置扩展nginx-rtmp-module模块,编译安装,下面的/home/hx/Downloads/nginx-rtmp-module 是 nginx-rtmp-module的下载目录。

cd nginx-1.13.8
./configure --add-module=/home/hx/Downloads/nginx-rtmp-module --with-debug
make
make install
6.配置RTMP及启动nginx

安装完后会显示安装目录,一般安装在/usr/local/nginx
更多配置请参考https://github.com/arut/nginx-rtmp-module/wiki/Directives
设置nginx.conf文件加入rtmp配置

vim /usr/local/nginx/conf/nginx.conf

加入以下内容,更详细的配置见模块的官网

rtmp_auto_push on;
rtmp {
    server {
        listen 1935;

        application mytv {
            live on;
        }
    }
}

启动

cd usr/local/nginx/sbin
./nginx

停止nginx服务
查看进程信息包括id

ps -ef |grep "nginx"

杀死进程

kill -9 id

猜你喜欢

转载自blog.csdn.net/dz_hexiang/article/details/79257733