Hls.js: Final segment failing to load, auto recover not helping

Created on 11 May 2017  路  3Comments  路  Source: video-dev/hls.js

Environment

Steps to reproduce
  1. Visit http://video-dev.github.io/hls.js/demo/?src=https%3A%2F%2Fsecure.brightcove.com%2Fservices%2Fmobile%2Fstreaming%2Findex%2Fmaster.m3u8%3FvideoId%3D5413886013001%26secure%3Dtrue&enableStreaming=true&autoRecoverError=true&enableWorker=true&dumpfMP4=false&levelCapping=-1&defaultAudioCodec=undefined and see that the last piece of the video fails to buffer.
  2. Watch the video or seek to near the end (before where it stops buffering)
  3. Once playback hits that point, the video freezes
  4. Auto-recover is on, however it does not appear to help
  5. Clicking 'recover Media Error' button does help (playback resumes from the proper point).

This behavior is observable here https://uw-media.ydr.com/video-wrap/embed?videoid=100991728 (video stops playing with ~5 seconds left).

Things to note:

  1. The video plays all the way through on iOS (we're allowing the device to handle the stream natively -- not using hls.js)
  2. I am integrating Hls.js into an HTML5 video player (custom). I've taken steps to try to resolve the issue using hls.recoverMediaError() and by using the technique here https://github.com/video-dev/hls.js/blob/master/demo/index.html#L739 to no avail. When I use this technique, playback restarts from the beginning and still fails when playback reaches the last fragment that is failing to buffer.
  3. It is working in a Brightcove player (I'm assuming they are handling the HLS error differently).
  4. ErrorTypes.MEDIA_ERROR is firing at the point of failure, but is marked as non-fatal (however it does seem to be a fatal error).

Any direction would be greatly appreciated.

Expected behavior

Uninterrupted playback, all fragments load and play

Actual behavior

Last piece (~last 5 seconds) fails to play

Console output
[warn] > playback stalling in low buffer @62.6753
(anonymous) @   hls.js:13218
_checkBuffer    @   hls.js:4659
doTick  @   hls.js:3621
tick    @   hls.js:3578

Sample integration code (attempting to handle error) that is not helping resolve this issue.

/**
 * Attempt to recover HLS playback, if all else fails revert to mp4
 */
handleHlsError: function (event, data) {
    let errorType = data.type;
    let isFatal = data.fatal;
    this.errorCount++;
    if (this.errorCount <= 2) {
        if (isFatal) {
            switch (errorType) {
                case this.Hls.ErrorTypes.NETWORK_ERROR:

                    // try to recover network error
                    this.hls.startLoad();
                    break;
                case this.Hls.ErrorTypes.MEDIA_ERROR:

                    // try to recover media error
                    this.handleMediaError();
                    break;
                default:

                    // cannot recover
                    this.killHls(true);
                    break;
            }
        }
    } else {
        this.killHls(true);
    }
},
handleMediaError: function () {
    var now = performance.now();
    if(!this.recoverDecodingErrorDate || (now - this.recoverDecodingErrorDate) > 3000) {
        this.recoverDecodingErrorDate = performance.now();
        console.log(",try to recover media Error ...");
        this.hls.recoverMediaError();
    } else {
        if(!this.recoverSwapAudioCodecDate || (now - this.recoverSwapAudioCodecDate) > 3000) {
            this.recoverSwapAudioCodecDate = performance.now();
            console.log(",try to swap Audio Codec and recover media Error ...");
            this.hls.swapAudioCodec();
            this.hls.recoverMediaError();
        } else {
            console.log(",cannot recover, last media error recovery failed ...");
        }
    }
},
Bug

Most helpful comment

I just issued a new release (v0.7.8)
enjoy !

All 3 comments

@harbinha it should be fixed now, could you recheck ?

@mangui Looks good! Thanks for fixing this. What is the release cycle like for getting this patch out? We're requiring hls.js from npm in our integration.

I just issued a new release (v0.7.8)
enjoy !

Was this page helpful?
0 / 5 - 0 ratings

Related issues

osamay picture osamay  路  4Comments

shalommeoded picture shalommeoded  路  3Comments

NicholasAsimov picture NicholasAsimov  路  3Comments

nickcartery picture nickcartery  路  4Comments

bharathsn0812 picture bharathsn0812  路  4Comments