Enable ABR 1080p<->720p; disable 480p (desynced); realistic bandwidth estimate

This commit is contained in:
Sebastjan 2026-04-25 12:06:28 +02:00
parent 7c2f4eee89
commit cb7e78eedd

View File

@ -664,14 +664,28 @@
manifestLoadingMaxRetry: 6, manifestLoadingMaxRetry: 6,
fragLoadingTimeOut: 20000, fragLoadingTimeOut: 20000,
fragLoadingMaxRetry: 6, fragLoadingMaxRetry: 6,
startLevel: -1, // ABR (Adaptive Bitrate) — let player auto-switch between qualities
capLevelToPlayerSize: false, startLevel: -1, // auto: start with whatever bandwidth allows
abrEwmaDefaultEstimate: 50000000, capLevelToPlayerSize: false, // don't cap to viewport size
testBandwidth: false, abrEwmaDefaultEstimate: 3000000, // realistic 3 Mbps starting estimate
testBandwidth: true, // probe bandwidth on startup
abrBandWidthFactor: 0.95, // 95% of measured BW → safety margin
abrBandWidthUpFactor: 0.7, // need 70% headroom before upgrading
}); });
hls.loadSource(HLS_URL); hls.loadSource(HLS_URL);
hls.attachMedia(video); hls.attachMedia(video);
hls.on(Hls.Events.MANIFEST_PARSED, () => { hls.on(Hls.Events.MANIFEST_PARSED, () => {
// Disable 480p variant (it's desynchronized from 1080p/720p on Rok's encoder)
// ABR will only switch between 1080p and 720p, both of which are in sync.
try {
if (hls.levels && hls.levels.length) {
hls.levels.forEach((lvl, idx) => {
if (lvl.height && lvl.height <= 480) {
lvl.enabled = false;
}
});
}
} catch (e) {}
hideMsg(); hideMsg();
video.play().catch(() => setTimeout(() => video.play().catch(() => {}), 200)); video.play().catch(() => setTimeout(() => video.play().catch(() => {}), 200));
}); });