perf: 优化后端性能与直播延迟,包含数据库WAL模式、流媒体写缓冲、转码 Preset 优化、聊天锁和指标采集优化,以及前端自动追帧功能

This commit is contained in:
2026-06-15 15:08:07 +08:00
parent 261b1ab169
commit e0a6923984
5 changed files with 150 additions and 24 deletions

View File

@@ -81,6 +81,7 @@
isLive: true,
}, {
enableWorker: false,
enableStashBuffer: false,
stashInitialSize: 128,
});
@@ -88,6 +89,24 @@
player.load();
player.play().catch(() => {});
// Live latency auto-catchup logic
video.addEventListener('timeupdate', function() {
if (video.buffered.length > 0) {
const end = video.buffered.end(video.buffered.length - 1);
const diff = end - video.currentTime;
if (diff > 5) {
// If way behind, jump directly close to the live edge
video.currentTime = end - 1.0;
} else if (diff > 1.5) {
// Speed up slightly to catch up
video.playbackRate = 1.15;
} else {
// Reset to normal speed
video.playbackRate = 1.0;
}
}
});
player.on(flvjs.Events.ERROR, function(errorType, detail, info) {
const parts = ['Live stream failed to load.'];
if (errorType) parts.push('type=' + errorType);