From 9fd2bf8fc680c00a5bd5aa056af2bbc89900075b Mon Sep 17 00:00:00 2001 From: "gao.zhiyuan" Date: Wed, 31 May 2023 15:55:29 +0800 Subject: [PATCH] =?UTF-8?q?flv=E6=92=AD=E6=94=BE=E5=BB=B6=E8=BF=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/sections/console/containers/index.js | 44 ++++++++++++++----- 1 file changed, 34 insertions(+), 10 deletions(-) diff --git a/console/client/src/sections/console/containers/index.js b/console/client/src/sections/console/containers/index.js index 28810de..57b263b 100644 --- a/console/client/src/sections/console/containers/index.js +++ b/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,29 +610,52 @@ 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(); - // 初始化 _remuxer - let controller = flv?._transmuxer?._controller - controller._remuxer = { - flushStashedSamples: function () { - console.log("flushStashedSamples") + try { + // 初始化 _remuxer + let controller = flv?._transmuxer?._controller + controller._remuxer = { + flushStashedSamples: function () { + 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); + } } })