
公式のnginxマニュアルに従って、ローカルコンピュータにRTMPサーバーを設定しました。
nginxを使用した遠隔学習用ビデオストリーミング
私のnginx設定:
sudo vim /usr/local/nginx/conf/nginx.conf
worker_processes 1;
error_log logs/error.log;
worker_rlimit_nofile 8192;
events {
worker_connections 1024;
}
rtmp {
server {
listen 1935;
application live {
live on;
interleave on;
hls on;
hls_path /mnt/hls;
hls_fragment 15s;
}
}
}
http {
default_type application/octet-stream;
server {
listen 80;
location /tv {
root /mnt/hls;
}
}
types {
application/vnd.apple.mpegurl m3u8;
video/mp2t ts;
text/html html;
}
}
RTMP URL設定:
output="rtmp://127.0.0.1:1935/live/sample"
ウェブカメラの宣伝:
ffmpeg -f v4l2 -video_size 640x480 -i /dev/video0 -c:v libx264 -f flv $output
rtmp プロトコルを使用してストリームを取得します。
ffplay rtmp://127.0.0.1:1935/live/sample
映像を正常に受け取りました。
hls プロトコルを使用してストリームを取得します。
ffplay http://127.0.0.1/live/sample
HTTP error 404 Not Found
http://127.0.0.1:80/live/sample.m3u8: Server returned 404 Not Found
#It can't get video with browser.
どうすれば修正できますか? httpセグメントの次のコードスニペットはどういう意味ですか?
server {
listen 80;
location /tv {
root /mnt/hls;
}
}
私はどこに行くべきですかmkdir /tv
?
答え1
答え2
httpとrtmp、hlsのpush urlとプルURLの間には関係があります。最初のグループ設定はうまく機能します。
Pull url
http://127.0.0.1/tv/sample.m3u8
Push url
rtmp://127.0.0.1:1935/live/sample
location /tv {
root /mnt/hls;
}
rtmp setting
application live {
live on;
interleave on;
hls on;
hls_path /mnt/hls;
}
http setting
location /tv {
root /mnt/hls;
}
また、上記のような機能を持つ次のペアで作成することもできます。
Pull url
http://127.0.0.1/tv/sample.m3u8
Push url
rtmp://127.0.0.1:1935/tv/sample
location /tv {
root /mnt;
}
rtmp setting
application tv {
live on;
interleave on;
hls on;
hls_path /mnt/tv;
}
http setting
location /tv {
root /mnt/hls;
}