监控视频流项目初步接触体验(二)

    这一篇,主要是介绍nginx的编译。同样,操作系统也是centos 6.9。后面的篇章,有在windows的试验记录,所以每一篇开头,我都会标明当前的操作系统。

    首先,下载源码:http://nginx.org/en/download.html

    第二步,先别忙着老一套的编译动作。因为需要添加nginx对rtmp的支持,所以先下载nginx-rtmp-module模块源码:https://github.com/arut/nginx-rtmp-module#example-nginxconf

    第三步:分别解压nginx源码与rtmp模块。注意,rtmp模块的路径一定要记住,假设解压后的模块路径为/path/to/rtmp-module

    第四步:(可选),如果您当前已经编译安装了nginx,那么请看一下nginx的编译选择nginx -V。比如:--user=www --group=www --prefix=/path/to/nginx --with-http_stub_status_module --without-http-cache --with-http_ssl_module --with-http_gzip_static_module

    第五步:进入nginx源码路径,编译老一套,但是这里请注意,完全重新编译与需要平滑升级(有执行第四步)的同学,有点区分,我们分别阐述两种情况。

    情况一(完全重新编译):

    ./configure --user=www --group=www --prefix=/path/to/nginx --with-http_stub_status_module --without-http-cache --with-http_ssl_module --with-http_gzip_static_module --add-module=/path/to/rtmp-module

    make

    make install

    情况二(平滑升级):

    ./configure 这里的编译选项为第四步看到的所有编项,之后再加上--add-module=/path/to/rtmp-module

    make   (这里千万别手贱运行make install)

    进入nginx源码路径下的objs目录,里面有一个nginx二进制可执行文件。将这个文件替换掉原来的nginx文件(替换之前,请先备份)

    第六步:添加nginx配置

    (1)在全局空间中添加rtmp配置

复制代码
rtmp {
    server {    
        listen 1935;    
        chunk_size 4096; 
        application myapp {    
            live on;    
        }    
        application hls {    
            live on;    
            hls on;    
            hls_path /tmp/hls;    
            hls_fragment 1s;     
            hls_playlist_length 3s;   
        }    
    }    
}  
复制代码

     (2)在server配置内添加

复制代码
location /hls {  
            types{  
                application/vnd.apple.mpegurl m3u8;  
                video/mp2t ts;  
            }
            root /tmp;
        
            add_header Cache-Control no-cache;
            add_header Access-Control-Allow-Origin *;
        }
复制代码

    (3) 为了同学更直观理解,上传以下两张图片

    

 

    第七步:重新加载配置

    nginx -s reload

 

    到这里,nginx就配置完成了。下一篇,将讲述ffmpeg与nginx如何配合工作。

 

posted on   咚..咚  阅读(316)  评论(0编辑  收藏  举报

编辑推荐:
· AI与.NET技术实操系列(二):开始使用ML.NET
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
· 理解Rust引用及其生命周期标识(上)
· 浏览器原生「磁吸」效果!Anchor Positioning 锚点定位神器解析
阅读排行:
· DeepSeek 开源周回顾「GitHub 热点速览」
· 记一次.NET内存居高不下排查解决与启示
· 物流快递公司核心技术能力-地址解析分单基础技术分享
· .NET 10首个预览版发布:重大改进与新特性概览!
· .NET10 - 预览版1新功能体验(一)
< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5

导航

点击右上角即可分享
微信分享提示