perf(player): switch to Buffer-First strategy to eliminate chaotic startup and micro-cuts

This commit is contained in:
Michael committed 2026-03-10 22:08:20 +01:00
1 parent 118887ab6f
commit 893ae7b03a
3 files changed
+69 -38

No files matched your search

+25 -16
View File
@@ -233,25 +233,27 @@
const hls = new Hls({
maxBufferLength: 60,
maxMaxBufferLength: 120,
liveSyncDurationCount: 5, // Balanced sync
liveSyncDurationCount: 10, // Buffer-First safety
liveMaxLatencyDurationCount: 20,
enableWorker: true,
lowLatencyMode: false, // Disabled for stability against micro-cuts
// Robustness
nudgeOffset: 0.6, // More aggressive jump over corrupted frames
nudgeMaxRetries: 25,
maxLiveSyncPlaybackRate: 1.2,
// Turbo-Start specific
startLevel: 0,
initialLiveManifestSize: 1,
abrEwmaDefaultEstimate: 700000,
manifestLoadingRetryDelay: 500,
levelLoadingRetryDelay: 500
lowLatencyMode: false,
nudgeOffset: 0.8,
nudgeMaxRetries: 30,
maxLiveSyncPlaybackRate: 1.1,
initialLiveManifestSize: 3,
abrEwmaDefaultEstimate: 1000000,
manifestLoadingRetryDelay: 1000,
levelLoadingRetryDelay: 1000
});
hls.loadSource(streamUrl);
hls.attachMedia(video);
hls.on(Hls.Events.MANIFEST_PARSED, () => {
video.play().catch(e => playOverlay.style.display = 'flex');
const checkBuffer = setInterval(() => {
if (video.buffered.length > 0 && video.buffered.end(0) > 1.5) {
clearInterval(checkBuffer);
video.play().catch(e => playOverlay.style.display = 'flex');
}
}, 200);
});
hls.on(Hls.Events.ERROR, (e, d) => {
if (d.fatal) {
@@ -271,13 +273,20 @@
url: streamUrl
}, {
enableWorker: true,
stashInitialSize: 128 * 1024, // Turbo Start: 128KB initial buffer
stashInitialSize: 512 * 1024,
enableStashBuffer: true,
maxStashSize: 20 * 1024 * 1024 // 20MB Max for stability
liveBufferLatencyChasing: false,
maxStashSize: 30 * 1024 * 1024
});
player.attachMediaElement(video);
player.load();
player.play().catch(e => playOverlay.style.display = 'flex');
const checkBuffer = setInterval(() => {
if (video.buffered.length > 0 && video.buffered.end(0) > 1.0) {
clearInterval(checkBuffer);
player.play().catch(e => playOverlay.style.display = 'flex');
}
}, 200);
return;
}