修复工作
This commit is contained in:
@@ -76,13 +76,15 @@ export default {
|
|||||||
},
|
},
|
||||||
flvOptionalConfig: {
|
flvOptionalConfig: {
|
||||||
enableWorker: false, // 禁用 Worker,便于调试
|
enableWorker: false, // 禁用 Worker,便于调试
|
||||||
enableStashBuffer: false, //关闭缓存
|
enableStashBuffer: true, // ⚠️ 必须启用缓存,否则无法播放
|
||||||
stashInitialSize: 128, // 减小初始缓存,加快启动
|
stashInitialSize: 128, // 初始缓存大小 (KB)
|
||||||
lazyLoad: false,
|
isLive: true, // 明确标记为直播流
|
||||||
|
lazyLoad: false, // 禁用懒加载
|
||||||
lazyLoadMaxDuration: 3 * 60,
|
lazyLoadMaxDuration: 3 * 60,
|
||||||
autoCleanupSourceBuffer: true,
|
autoCleanupSourceBuffer: true, // 自动清理缓冲区
|
||||||
autoCleanupMaxBackwardDuration: 3 * 60,
|
autoCleanupMaxBackwardDuration: 3 * 60,
|
||||||
autoCleanupMinBackwardDuration: 2 * 60,
|
autoCleanupMinBackwardDuration: 2 * 60,
|
||||||
|
fixAudioTimestampGap: true, // 修复音频时间戳间隙
|
||||||
// 关键:启用详细日志
|
// 关键:启用详细日志
|
||||||
enableLogging: true,
|
enableLogging: true,
|
||||||
logLevel: 'debug'
|
logLevel: 'debug'
|
||||||
@@ -98,7 +100,13 @@ export default {
|
|||||||
|
|
||||||
// 监听 flv.js 的统计信息
|
// 监听 flv.js 的统计信息
|
||||||
this.player.flv.on('statistics_info', (stats) => {
|
this.player.flv.on('statistics_info', (stats) => {
|
||||||
console.log('📈 flv.js 统计:', stats);
|
console.log('📈 flv.js 统计:', {
|
||||||
|
speed: stats.speed,
|
||||||
|
videoBufferSize: stats.videoBufferSize,
|
||||||
|
audioBufferSize: stats.audioBufferSize,
|
||||||
|
decodedFrames: stats.decodedFrames,
|
||||||
|
droppedFrames: stats.droppedFrames
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
// 监听 flv.js 的错误
|
// 监听 flv.js 的错误
|
||||||
@@ -107,7 +115,27 @@ export default {
|
|||||||
console.error(' 类型:', errorType);
|
console.error(' 类型:', errorType);
|
||||||
console.error(' 详情:', errorDetail);
|
console.error(' 详情:', errorDetail);
|
||||||
console.error(' 信息:', errorInfo);
|
console.error(' 信息:', errorInfo);
|
||||||
|
|
||||||
|
// 常见错误处理提示
|
||||||
|
if (errorType === 'NetworkError') {
|
||||||
|
console.error(' => 网络错误,检查后端服务是否正常');
|
||||||
|
} else if (errorType === 'MediaError') {
|
||||||
|
console.error(' => 媒体解码错误,可能是视频格式不支持');
|
||||||
|
console.error(' => 请确认后端 FFmpeg 使用 H.264 (baseline) + AAC 编码');
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// 监听元数据解析
|
||||||
|
this.player.flv.on('metadata_arrived', (metadata) => {
|
||||||
|
console.log('📦 FLV 元数据:', metadata);
|
||||||
|
});
|
||||||
|
|
||||||
|
// 监听视频数据解析
|
||||||
|
this.player.flv.on('scriptdata_arrived', (data) => {
|
||||||
|
console.log('📜 FLV 脚本数据:', data);
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
console.warn('⚠️ flv.js 实例不存在,无法监听事件');
|
||||||
}
|
}
|
||||||
|
|
||||||
// 监听播放器错误
|
// 监听播放器错误
|
||||||
|
|||||||
Reference in New Issue
Block a user