樹莓派rtmp服務器搭建


首先需要下載

nginx-1.8.1 : http://nginx.org/download/nginx-1.8.1.tar.gz

nginx-rtmp-module : https://github.com/arut/nginx-rtmp-module

安裝nginx
1.安裝nginx-1.8.1
wget http://nginx.org/download/nginx-1.8.1.tar.gz

2.安裝依賴
安裝 PCRE 正則依賴庫
sudo apt-get install libpcre3 libpcre3-dev
下載openssl-1.0.1
wget https://www.openssl.org/source/old/1.0.1/openssl-1.0.1u.tar.gz

3.解壓
tar -xvf nginx-1.8.1.tar.gz -C /usr/local/live

4.配置
//修改默認監聽端口
vi conf/nginx.conf

5.添加nginx-rtmp-module模塊並編譯安裝
將下載的nginx-rtmp-module文件解壓,進入第3步解壓完的nginx-1.8.1文件夾中

./configure --add-module=../nginx-rtmp-module --prefix=/usr/local/live/nginx
make
make install

在編譯步驟出現如下錯誤:
cc1: all warnings being treated as errors
objs/Makefile:460: recipe for target 'objs/src/core/ngx_murmurhash.o' failed
make[1]: *** [objs/src/core/ngx_murmurhash.o] Error 1
make[1]: Leaving directory '/home/wzj/tools/nginx/nginx-1.11.3'
Makefile:8: recipe for target 'build' failed
make: *** [build] Error 2

解決辦法
找到對應的Maakefile文件,將gcc參數中的-Werror去掉。
我上面顯示的是./objs/Makefile文件,我打開看了下,將第三行的-Werror去掉就可以

6.運行nginx,進入第5步安裝完后的nginx文件

./sbin/nginx

搭建流媒體服務器相關配置
1.繼續上面的第4步
``
events {
worker_connections 1024;
}

//添加的部分
rtmp {
server {
listen 82;#之后推流拉流的端口
chunk_size 4096;

    application live {  
        live on;
    }
}

}

server {
listen 81;
server_name localhost;

    #charset koi8-r;

    #access_log  logs/host.access.log  main;
  
    #添加的部分
    location /stat {
        rtmp_stat all;
        rtmp_stat_stylesheet stat.xsl;
    }
    location /stat.xsl {
        #為nginx-rtmp-module解壓的地址
        root /usr/local/live/nginx-rtmp-module/;
    }
 
    location / {
        root   html;
        index  index.html index.htm;
    }
}

``
配置完成后重啟nginx
./sbin/nginx -s reload

瀏覽器url: http:// + 服務器ip +: + 端口號 + /stat

這時候就可以試試推流給流媒體服務器了。


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM