Nginx 搭建rtmp直播服务器
1.到nginx源码目录新建个rtmp目录 ,进入 git clone https://github.com/arut/nginx-rtmp-module.git
2.重编译nginx 代码如下
[Shell] 纯文本查看 复制代码
|
1
2
3
|
./configure --prefix=/usr/local/nginx-1.2.9/ --add-module=./rtmp/nginx-rtmp-module --with-http_ssl_module --with-pcre=/lamp_source/pcre-8.38; make;make install;#重新安装nginx |
3.完成安装后。
打开nginx.conf 在http{server...} 之后加上以下代码
[AppleScript] 纯文本查看 复制代码
|
01
02
03
04
05
06
07
08
09
10
11
12
|
rtmp{ server{ listen 1935; chunk_size 4000; application hls { live on; hls on; hls_path /你的服务器路径这个用于存放缓存文件的。必须可写; hls_fragment 5s; } }} |
然后新建个主机配置
[AppleScript] 纯文本查看 复制代码
|
01
02
03
04
05
06
07
08
09
10
11
12
13
14
15
16
|
server { listen 8851; location /index.html { root /网站存放目录;} location / {# return 403; # Serve HLS fragments types { application/vnd.apple.mpegurl m3u8; video/mp2t ts; } root /同上,缓存用; expires -1; } } |
完成以上配置后。 下载一个软件叫做 open broadcaster software 的软件推流即可(注意,也可以使用ffmpeg 进行推流)。 软件使用如截图
然后点开始串流就可以了。
下载打开vlc播放器(拉流)。输入 rtmp://你的网址:1935/hls/上图中的密码 然后就ok了。 成功在线直播
将来不迎,当下不杂,过往不念。

浙公网安备 33010602011771号