zoukankan      html  css  js  c++  java
  • 监控视频流项目初步接触体验(二)

        这一篇,主要是介绍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如何配合工作。

  • 相关阅读:
    Android Studio自定义模板代码
    Android Studio自定义模板代码
    Android Studio自定义模板代码
    android studio 首字母提示 设置 大小写敏感
    android studio 首字母提示 设置 大小写敏感
    新入公司 问问题 ,快速了解代码的方法
    新入公司 问问题 ,快速了解代码的方法
    gradle编译很慢解决方法
    gradle编译很慢解决方法
    被relativeLayout的grivate center 折腾死了
  • 原文地址:https://www.cnblogs.com/ddcoder/p/9072659.html
Copyright © 2011-2022 走看看