nginx-http-flv-module flv拉流錯誤整理

1.flv拉流錯誤

Uncaught (in promise) DOMException: play() failed because the user didn't interact with the document first. https://goo.gl/xX8pDD

在video標籤中加入 muted 即可

<video muted id="videoElement" class="centeredVideo" controls autoplay width="1024" height="576">
Your browser is too old which doesn't support HTML5 video.
</video>

2.HTML採用flv.js與dplayer播放器來播放http-flv格式視頻時,請求nignx服務器遇到了chrom跨域的問題


Access to fetch at ‘http://192.168.31.66:9999/zzh-1586620072-2020-04-11-23_47_52.flv’ from origin ‘http://localhost:8080’ has been blocked by CORS policy: No ‘Access-Control-Allow-Origin’ header is present on the requested resource. If an opaque response serves your needs, set the request’s mode to ‘no-cors’ to fetch the resource with CORS disabled.

http{
    server {
        listen      8000;
        server_name localhost;
        add_header 'Access-Control-Allow-Origin' '*'; #允許所有來源訪問
        add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS, PUT, DELETE'; #允許訪問的方式

3.推流權限控制

rtmp {  
    server {  
        listen 1935;  #監聽的端口
        chunk_size 4000;
        application myapp {
            live on;
            notify_method get;
            publish_notify on;
            on_publish http://192.168.0.103:8087/autho/rtmp; #這裏進行權限控制
			on_publish_done http://127.0.0.1:8087/autho/rtmpOver;#直播結束回調
        }  
        application hls {
            live on;
            hls on;
            hls_path /home/soap/rtmp/hls;#視頻流存放地址
            hls_fragment 5s;
            hls_playlist_length 15s;
            hls_continuous on; #連續模式。
            hls_cleanup on;    #對多餘的切片進行刪除。
            hls_nested on;     #嵌套模式。
        }
    }  
}

4.flv拉取流的路徑

http://example.com[:port]/dir?[port=xxx&]app=appname&stream=streamname

http://127.0.0.1:8000/live?app=myapp&stream=fhx

port默認爲1935

myapp爲配置路徑

fhx爲流路徑

5.obs設置

6.效果圖

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章