flv.js icon indicating copy to clipboard operation
flv.js copied to clipboard

有没有知道累积延时要如何解决,是pts的算法造成的吗?

Open amhoho opened this issue 5 years ago • 10 comments

flv.js有个很致命的问题就是播放久了,累积延时就很严重,比如播放个10分钟后可能延时了十来秒。不知道怎么解决。。。

amhoho avatar Sep 26 '19 08:09 amhoho

每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
                }
            }
        }
    }

xqdd avatar Oct 02 '19 14:10 xqdd

我也遇到这个问题,flv.js能不能设置一下最大缓存帧数,如果超过了就丢弃找到下一个关键帧开始播放。

qiuqiuggt173 avatar Oct 21 '19 06:10 qiuqiuggt173

这个方法可以,但是有时候需要尝试几次才有效,感觉还是MSE对流数据格式要求严格导致

lynxerzhang avatar Nov 11 '19 08:11 lynxerzhang

每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吧

DrLambs avatar Dec 30 '19 12:12 DrLambs

我也在折腾这个问题。。目前也是采用定时器来检查缓存长度。。我定时器设的比较短,5秒检查一次。 缓存被清空后,拉到的数据里没有关键帧,画面停住了。还没等下一个关键帧进来,定时器又触发了。。导致直接变成了幻灯片。 所以定时器触发时间不能设太短。 但我还是觉得可以封装一下,把缓存长度直接作为参数暴露出来

qyc898 avatar Sep 01 '20 13:09 qyc898

不行啊,如果设置定时器去追赶 就会跳帧 @qyc898

ouzhou avatar Sep 02 '20 14:09 ouzhou

每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
                }
            }
        }
    }

跳帧严重,有没有更好的解决办法

myf-sky avatar Sep 18 '20 08:09 myf-sky

我也有这个问题,如何解决啊?

atlas1119 avatar Mar 02 '21 07:03 atlas1119

下面的代码一百毫秒执行一次,没有卡顿的感觉 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 } } } }

chenmingli avatar Apr 11 '23 02:04 chenmingli

flv.js有个很致命的问题就是播放久了,累积延时就很严重,比如播放个10分钟后可能延时了十来秒。不知道怎么解决。。。

我也是,无论是追帧还是跳帧,其实最新的流已经append了,但是video缓冲区最后总有一部分是播放不了了,跳到对应的缓冲区域会暂停住,等到能播放的时候最新的进度已经延迟很久了,播放越久延迟越大,只能重置整个video才能解决这个延迟问题,还没找到别的解决方案

Lilinjie01 avatar Jul 06 '23 13:07 Lilinjie01