1.ダウンロードモジュール(nginx-rtmp-module)
1 cd / data / nginx 2 yum install git 3 git clone https:// github.com/arut/nginx-rtmp-module.git
2. nginxをインストールします。
1 yum install gcc make pcre-devel openssl- devel 2 wget http:// nginx.org/download/nginx-1.15.0.tar.gz 3 tar xf nginx- 1.15。0 .tar.gz 4 cd nginx- 1.15。0 5 ./configure --with-http_ssl_module --add-module = .. / nginx-rtmp- module 6 make && make install
3. nginx設定ファイルを変更します
1 rtmp { 2 server { 3 listen 1935 ; #listening port 4 chunk_size 4000 ; #packet size、default 4096、the value the big 、the lower CPU、 is not least the 128 5 6 application hls {#rtmp push stream request path 7 live on; #ライブ 8 hlsをオンにする; #hls 9を オンにするhls_path / usr / share / nginx / html / hls; #rtmpプッシュストリームファイルストレージパス、読み取りおよび書き込み権限 10 hls_fragment 5s;#各TSファイルに5秒含まれるビデオコンテンツ 11 } 12 } 13 }
4.プッシュフロー
ffmpegプッシュストリーム
推流: ffmpeg -re -i /path/file.mp4 -vcodec copy-acodec copy -f flv rtmp:// 192.168.4.11:1935/hls
obsプッシュストリーム
obsソフトウェアをダウンロードし、設定をクリックして、URL:rtmp:// IP:1935 / hls、ストリーム名:部屋番号
新しいVLCローカルビデオを作成し、ストリーミングを開始します。ストリーミングの複数のソース(ローカルビデオ、画像、外部デバイス)があり、/ usr / local / nginx / html / hlsディレクトリにあるファイルを表示します
5.ライブ放送を見る(プルストリーム)
HTML5をサポートするブラウザー(Microsoft Edge)で遊ぶ
cat / usr / local / nginx / html / test.html <video> <source src = " http://192.168.4.11/hls/test.m3u8 " /> <p class = " warning " >お使いのブラウザはサポートしていませんHTML5ビデオ。</ p> </ video>
ソフトウェアVLCで遊ぶ
ストリームアドレス:http:// 192.168.4.11/hls/test.m3u8