Browse Source

flv播放延迟

simplify_dependencies
巴林闲侠 2 years ago
parent
commit
9fd2bf8fc6
  1. 34
      console/client/src/sections/console/containers/index.js

34
console/client/src/sections/console/containers/index.js

@ -46,6 +46,7 @@ let dataLiveWs;
let lidarLiveWs;
let dataLiveWsInterval;
let lidarLiveWsInterval;
let flvPlayerInterval;
function Index (props) {
const { dispatch, craneData } = props
const xyCvs = useRef()
@ -609,17 +610,22 @@ function Index (props) {
hasAudio: false,
hasVideo: true,
}, {
enableWorker: false,
enalleStashBuffer: true,
enableWorker: false,//分离线程
enalleStashBuffer: false, //IO隐藏缓冲区
stashInitialSize: 128,
lazyLoadMaxDuration: 3 * 60,
isLive: true,
lazyLoad: false,
// lazyLoadMaxDuration: 3 * 60,
lazyLoadMaxDuration: 1,
seekType: 'range',
autoCleanupSourceBuffer: true,
cors: true,
// cors: true,
// stashInitialSize: 1024
});
flv.attachMediaElement(container);
flv.load();
try {
// 初始化 _remuxer
let controller = flv?._transmuxer?._controller
controller._remuxer = {
@ -627,11 +633,29 @@ function Index (props) {
console.log("flushStashedSamples")
}
}
} catch (error) {
console.error(error);
}
flv.play();
flvPlayer.current = flv
if (flvPlayerInterval) {
clearInterval(flvPlayerInterval)
}
// flvPlayerInterval = setInterval(() => {
// console.log(flv.buffered);
// if (flv.buffered.length) {
// let end = flv.buffered.end(0);//获取当前buffered值
// let diff = end - flv.currentTime;//获取buffered与currentTime的差值
// if (diff >= 3) {//如果差值大于等于0.5 手动跳帧 这里可根据自身需求来定
// console.log(222222222);
// flv.currentTime = flv.buffered.end(0);//手动跳帧
// }
// }
// }, 1000 * 10);
} catch (error) {
console.error(error);
}
}
})

Loading…
Cancel
Save