我最近开始使用nginx和video.js来建立一个活动流。问题:如果我使用视频as控制质量-级别和视频levels质量选择器作为video.js的加载项,他们应该自动插入一个基于下载播放列表的质量选择器和hls变体。但事实并非如此,它只是在激活自动选项的情况下添加了质量菜单。为什么HLS播放列表或播放机不访问变体并呈现正确的菜单?
版本:
视频:7.6.6
视频.质量.等级: 2.0.9
视频hls hls-质量-选择器: 1.1.1
下面是插入并启动播放机的代码:
this.videoJSplayer = videojs('video_player', {
html5: {
hls: {
overrideNative:true,
//withCredentials: true
},
controls: false,
autoplay: false,
preload: 'auto'
}
this.videoJSplayer.src([{type:'application/x-mpegURL',src: URL + ".m3u8"}]);
this.videoJSplayer.controls('true');
this.videoJSplayer.play();
this.isButtonVisible = false;
this.videoJSplayer.hlsQualitySelector();我的播放列表是这样的:
#EXT-X-STREAM-INF:PROGRAM-ID=1,CLOSED-CAPTIONS=NONE,BANDWIDTH=288000
test2_low.m3u8
#EXT-X-STREAM-INF:PROGRAM-ID=1,CLOSED-CAPTIONS=NONE,BANDWIDTH=2048000
test2_hd720.m3u8
#EXT-X-STREAM-INF:PROGRAM-ID=1,CLOSED-CAPTIONS=NONE,BANDWIDTH=4096000
test2_src.m3u8发布于 2020-03-23 17:32:28
解决方案相当简单:在播放列表中添加选项解析,如
hls_variant _src BANDWIDTH=4096000 RESOLUTION=1920x1080;这将使插件能够正确地呈现选择器。没有这方面的手册。
配置现在如下所示
worker_processes 1;
events {
worker_connections 1024;
}
# RTMP configuration
rtmp {
server {
listen 1935; # Listen on standard RTMP port
chunk_size 2048;
# This application is to accept incoming stream
application 00kSLqEV5a6LYVfFa1jG {
live on; # Allows live input
exec ffmpeg -i rtmp://127.0.0.1/$app/$name
-c:v libx264 -c:a libfdk_aac -b:v 768k -b:a 96k -vf "scale=720:trunc(ow/a/2)*2" -tune zerolatency -preset veryfast -crf 23 -f flv rtmp://127.0.0.1/show/$name_low
-c:v libx264 -c:a libfdk_aac -b:v 1920k -b:a 128k -vf "scale=1280:trunc(ow/a/2)*2" -tune zerolatency -preset veryfast -crf 23 -f flv rtmp://127.0.0.1/show/$name_hd720
-c copy -f flv rtmp://127.0.0.1/show/$name_src;
on_publish #server_auth;
}
application show {
live on;
# Turn on HLS
hls on;
hls_path #YOUR_PATH;
hls_fragment 5;
hls_playlist_length 30;
# disable consuming the stream from nginx as rtmp
allow publish 127.0.0.1;
allow publish 139.18.13.224;
deny publish all;
hls_variant _low BANDWIDTH=288000 RESOLUTION=848x480;
hls_variant _hd720 BANDWIDTH=2048000 RESOLUTION=1280x720;
hls_variant _src BANDWIDTH=4096000 RESOLUTION=1920x1080;
}
}
}
http {
sendfile off;
tcp_nopush on;
# aio on;
directio 512;
default_type application/octet-stream;
include /usr/local/nginx/conf/mime.types;
server {
listen 80;
location / {
# Disable cache
add_header 'Cache-Control' 'no-cache';
# rewrite ^(/hls)/(\w+)$ $1/$200kSLqEV5a6LYVfFa1jG.m3u8;
# CORS setup
add_header 'Access-Control-Allow-Origin' '*' always;
add_header 'Access-Control-Expose-Headers' 'Content-Length';
add_header 'X-Frame-Options' 'DENY' always;
# allow CORS preflight requests
if ($request_method = 'OPTIONS') {
add_header 'Access-Control-Allow-Origin' '*' always;
add_header 'Access-Control-Max-Age' 1728000;
add_header 'Content-Type' 'text/plain charset=UTF-8';
add_header 'Content-Length' 0;
return 204;
}
types {
application/dash+xml mpd;
application/vnd.apple.mpegurl m3u8;
video/mp2t ts;
text/html html;
application/x-javascript js;
# text/javascript js;
text/css css;
}
index index.html;
root #stream_root;
location ~ \.php$ {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/php-fpm.sock;
set $path_info $fastcgi_path_info;
fastcgi_param PATH_INFO $path_info;
fastcgi_index index.php;
include fastcgi.conf;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param SCRIPT_NAME $fastcgi_script_name;
fastcgi_param HTTP_PROXY "";
proxy_set_header X-Forwarded-Uri /matomo;
}
}
}
}https://stackoverflow.com/questions/60817032
复制相似问题