溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊(cè)×
其他方式登錄
點(diǎn)擊 登錄注冊(cè) 即表示同意《億速云用戶服務(wù)條款》

nginx搭建直播

發(fā)布時(shí)間:2020-02-14 11:10:16 來(lái)源:網(wǎng)絡(luò) 閱讀:210 作者:lxhllf2005 欄目:開(kāi)發(fā)技術(shù)
1.搭建nginx直播
2.使用安卓推流
3.使用html播放

環(huán)境虛擬機(jī): ip: 192.168.1.181
        設(shè)置:
        vi /etc/sysconfig/network-script/ifcfg-ens33
        IPADDR=192.168.1.181
        GATEWAY=192.168.1.1
        NETMASK=255.255.255.0
        DNS1=192.168.1.1

1.搭建nginx直播

1-1.安裝編譯所需軟件:

yum -y install git pcre pcre-devel zlib zlib-devel gcc openssl openssl-devel wget zip unzip

1-2.安裝編譯所需軟件:

wget http://nginx.org/download/nginx-1.14.1.tar.gz -P /usr/local/src/
git clone git://github.com/arut/nginx-rtmp-module.git /usr/local/src/nginx-rtmp-module
tar -zxvf /usr/local/src/nginx-1.14.1.tar.gz -C /usr/local/src/
cd /usr/local/src/nginx-1.14.1/
./configure --with-http_ssl_module --add-module=../nginx-rtmp-module
make && make install

1-3.啟動(dòng)nginx:

/usr/local/nginx/sbin/nginx
    測(cè)試:
        瀏覽器訪問(wèn):http://192.168.1.181

1-4.配置nginx: /usr/local/nginx/nginx.conf

http {
    ....
    server {
        listen       80;
        ....
        # rtmp stat
        location /stat {
            rtmp_stat all;
            rtmp_stat_stylesheet stat.xsl;
        }
        location /stat.xsl {
            # you can move stat.xsl to a different location
            root /usr/build/nginx-rtmp-module;
        }

        # rtmp control
        location /control {
            rtmp_control all;
        }

        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }
    }
}

rtmp {
    server {
        listen 1935;
        ping 30s;
        notify_method get;

        application myapp {
            live on;
        }
    }
}

2.使用安卓推流

下載推流app,名字叫: 【i直播】

3.使用html播放

拉流地址: rtmp://192.168.1.181/myapp/mystream
播放使用: ckplayer
本地搭建web服務(wù),將代碼部署上去: 

ckplayer下載地址

向AI問(wèn)一下細(xì)節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI