Ubuntu源码编译Nginx + rtmp模块

1. 下载稳定当前版本nginx:http://nginx.org/en/download.html

nginx-1.16.1.tar.gz

 

2. 下载nginx rtmp 模块:https://github.com/arut/nginx-rtmp-module

 

3. 解压这两个文件,进入 

nginx-1.16.1 目录,

安装依赖包: gcc, g++
安装必要的库: zlib, pcre, openssl

执行  ./configure --add-module=/mnt/d/app/nginx/nginx-rtmp-module --prefix=/mnt/d/app/nginx/nginx_bin

module  路径要为 绝对路径。

prefix     为要安装到哪里

然后

make -j16&& make install

 

4.  进入 安装目录,上面的例子为: /mnt/d/app/nginx/nginx_bin

进入 sbin,执行 ./nginx

 

5. 到浏览器 输入 http://你的ip地址

可以看到:

 

 

6. nginx + rtmp 配置

新建一个 config 文件:

比如:nginx.rtmp.diaobaole.tech

内容如下:

rtmp {

  server {
    listen 1935;
    chunk_size 4096;
  
    application live { 
        live on;
        hls on;
        hls_path 你自己的路径;
        hls_fragment 2s;
        hls_playlist_length 5s;
    }

  }

}

 

然后在 nginx.conf 中 使用include:

include nginx.rtmp.diaobaole.tech;

在http server中添加下面的配置 HLS:



location /zhibo {
    rtmp_stat all;
    rtmp_stat_stylesheet stat.xsl;
}


location /stat.xsl {
    root /download/nginx-rtmp-module/;  #改成你自己的路径


location /livehls {

    types {
        application/vnd.apple.mpegurl m3u8;
        video/mp2t ts;
    }
    
    alias 你自己的路径;           # 别人访问你的路径就是这个路径
    add_header Cache-Control no-cache;
}


重新启动nginx

killall nginx
重启 nginx

 

7.  ffmpeg 进场

ffmpeg 主要是用来往nginx rtmp服务器推流的

./ffmpeg/out/bin/ffmpeg  -re -stream_loop -1 -i /download/output.mov  -vcodec copy -acodec copy -f flv rtmp://172.18.147.152:1935/live/show

-i 表示输入的片源

-f 表示格式

rtmp://172.18.147.152:1935/live/show 表示要往 rtmp server的 live 应用的 show 频道 推流, 后面这个show可以随意改变

 

8. 使用播放器播放:

例如我的例子是:

http://www.diaobaole.tech/hls/live/show.m3u8

 

 

 

 

 

 

 

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Tui_GuiGe

鼓励一下作者吧,请他喝一瓶啤酒

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值