Nginx搭建rtmp直播服務(wù)器實現(xiàn)代碼
1.到nginx源碼目錄新建個rtmp目錄 ,進(jìn)入 git clone https://github.com/arut/nginx-rtmp-module.git
2.重編譯nginx 代碼如下
./configure --prefix=/usr/local/nginx-1.2.9/ --add-module=./rtmp/nginx-rtmp-module --with-http_ssl_module --with-pcre=/lamp_source/pcre-8.38;
make;make install;
#重新安裝nginx
3.完成安裝后。
打開nginx.conf 在http{server...} 之后加上以下代碼
rtmp{ server{ listen 1935; chunk_size 4000; application hls { live on; hls on; hls_path /你的服務(wù)器路徑這個用于存放緩存文件的。必須可寫; hls_fragment 5s; } } }
然后新建個主機配置
server { listen 8851; location /index.html { root /網(wǎng)站存放目錄; } location / {# return 403; # Serve HLS fragments types { application/vnd.apple.mpegurl m3u8; video/mp2t ts; } root /同上,緩存用; expires -1; } }
完成以上配置后。 下載一個軟件叫做 open broadcaster software 的軟件推流即可(注意,也可以使用ffmpeg 進(jìn)行推流)。 軟件使用如截圖
然后點開始串流就可以了。
下載打開vlc播放器(拉流)。輸入 rtmp://你的網(wǎng)址:1935/hls/上圖中的密碼 然后就ok了。 成功在線直播
以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持本站。
版權(quán)聲明:本站文章來源標(biāo)注為YINGSOO的內(nèi)容版權(quán)均為本站所有,歡迎引用、轉(zhuǎn)載,請保持原文完整并注明來源及原文鏈接。禁止復(fù)制或仿造本網(wǎng)站,禁止在非www.sddonglingsh.com所屬的服務(wù)器上建立鏡像,否則將依法追究法律責(zé)任。本站部分內(nèi)容來源于網(wǎng)友推薦、互聯(lián)網(wǎng)收集整理而來,僅供學(xué)習(xí)參考,不代表本站立場,如有內(nèi)容涉嫌侵權(quán),請聯(lián)系alex-e#qq.com處理。