flv.js
flv.js copied to clipboard
有没有知道累积延时要如何解决,是pts的算法造成的吗?
flv.js有个很致命的问题就是播放久了,累积延时就很严重,比如播放个10分钟后可能延时了十来秒。不知道怎么解决。。。
每10分钟跳到最新的缓存下
componentDidMount() {
this.cleanBuff = setInterval(this.jumpToEndBuffer, 3 * 10 * 1000)
}
jumpToEndBuffer = () => {
if (this.video) {
let buffered = this.video.buffered
if (buffered.length > 0) {
let end = buffered.end(0)
if (end - this.video.currentTime > 0.15) {
this.video.currentTime = end - 0.1
}
}
}
}
我也遇到这个问题,flv.js能不能设置一下最大缓存帧数,如果超过了就丢弃找到下一个关键帧开始播放。
这个方法可以,但是有时候需要尝试几次才有效,感觉还是MSE对流数据格式要求严格导致
每10分钟跳到最新的缓存下
componentDidMount() { this.cleanBuff = setInterval(this.jumpToEndBuffer, 3 * 10 * 1000) } jumpToEndBuffer = () => { if (this.video) { let buffered = this.video.buffered if (buffered.length > 0) { let end = buffered.end(0) if (end - this.video.currentTime > 0.15) { this.video.currentTime = end - 0.1 } } } }
你这是30s吧
我也在折腾这个问题。。目前也是采用定时器来检查缓存长度。。我定时器设的比较短,5秒检查一次。 缓存被清空后,拉到的数据里没有关键帧,画面停住了。还没等下一个关键帧进来,定时器又触发了。。导致直接变成了幻灯片。 所以定时器触发时间不能设太短。 但我还是觉得可以封装一下,把缓存长度直接作为参数暴露出来
不行啊,如果设置定时器去追赶 就会跳帧 @qyc898
每10分钟跳到最新的缓存下
componentDidMount() { this.cleanBuff = setInterval(this.jumpToEndBuffer, 3 * 10 * 1000) } jumpToEndBuffer = () => { if (this.video) { let buffered = this.video.buffered if (buffered.length > 0) { let end = buffered.end(0) if (end - this.video.currentTime > 0.15) { this.video.currentTime = end - 0.1 } } } }
跳帧严重,有没有更好的解决办法
我也有这个问题,如何解决啊?
下面的代码一百毫秒执行一次,没有卡顿的感觉
fixedPaused() { if (this.flvPlayer) { const decodedFrames = this.flvPlayer?.statisticsInfo.decodedFrames // if (!decodedFrames) return if (this.lastDecodedFrame === decodedFrames && !this.isPaused) { this.stuckTime++ if (this.stuckTime > 10) { console.log('画面卡住了', this.source) this.stuckTime = 0 this.init() } } else { this.lastDecodedFrame = decodedFrames this.stuckTime = 0 // 修正视频直播流 if (this.flvPlayer?.buffered.length) { let end = this.flvPlayer.buffered.end(0) //获取当前buffered值(缓冲区末尾) let delta = end - this.flvPlayer.currentTime //获取buffered与当前播放位置的差值 // 延迟过大,通过跳帧的方式更新视频 if (delta > 0.5 || delta < 0) { this.flvPlayer.currentTime = this.flvPlayer.buffered.end(0) - 0.2 // this.flvPlayer.playbackRate = 1; } this.flvPlayer.playbackRate = 1 + delta * 3 } } } }
flv.js有个很致命的问题就是播放久了,累积延时就很严重,比如播放个10分钟后可能延时了十来秒。不知道怎么解决。。。
我也是,无论是追帧还是跳帧,其实最新的流已经append了,但是video缓冲区最后总有一部分是播放不了了,跳到对应的缓冲区域会暂停住,等到能播放的时候最新的进度已经延迟很久了,播放越久延迟越大,只能重置整个video才能解决这个延迟问题,还没找到别的解决方案