Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

When I use a HEVC 256 stream, VLC can play normally, but HLS cannot play normally #6895

Open
5 tasks done
XiaoxiRao opened this issue Dec 7, 2024 · 4 comments
Open
5 tasks done

Comments

@XiaoxiRao
Copy link

What version of Hls.js are you using?

1.6.0

What browser (including version) are you using?

Chrome version 131.0.6778.86 (arm64)

What OS (including version) are you using?

mac

Test stream

https://schoolfighting.oss-cn-hangzhou.aliyuncs.com/test/teshh265/output.m3u8

Configuration

{
    liveDurationInfinity: true,
    levelLoadingTimeOut: 15000,
    fragLoadingTimeOut: 25000,
    enableWorker: true,
    nudgeMaxRetry: 1000,
  }

Additional player setup steps

No response

Checklist

Steps to reproduce

  1. Open the webpage
  2. Click to play

Expected behaviour

Play normally

What actually happened?

Interface black screen

Console output

{
    "type": "mediaError",
    "details": "fragParsingError",
    "fatal": false,
    "error": {},
    "frag": {
        "_byteRange": null,
        "_url": "https://schoolfighting.oss-cn-hangzhou.aliyuncs.com/test/teshh265/6719b8152cdfb78408001bb7(1).ts",
        "_stats": {
            "aborted": false,
            "loaded": 0,
            "retry": 0,
            "total": 229360,
            "chunkCount": 1,
            "bwEstimate": 431649.13465134724,
            "loading": {
                "start": 28576.299999952316,
                "first": 28577.600000023842,
                "end": 28578.299999952316
            },
            "parsing": {
                "start": 28578.399999976158,
                "end": 28589.899999976158
            },
            "buffering": {
                "start": 0,
                "first": 0,
                "end": 28590.199999928474
            }
        },
        "_streams": {
            "audio": null,
            "video": null,
            "audiovideo": null
        },
        "base": {
            "url": "https://schoolfighting.oss-cn-hangzhou.aliyuncs.com/test/teshh265/output.m3u8"
        },
        "relurl": "6719b8152cdfb78408001bb7(1).ts",
        "_decryptdata": null,
        "_programDateTime": null,
        "_ref": null,
        "rawProgramDateTime": null,
        "tagList": [
            [
                "INF",
                "10"
            ]
        ],
        "duration": 10,
        "sn": 2,
        "type": "main",
        "loader": null,
        "keyLoader": null,
        "level": 0,
        "cc": 0,
        "start": 20,
        "playlistOffset": 20,
        "bitrateTest": false,
        "title": null,
        "initSegment": null,
        "gap": true,
        "urlId": 0
    },
    "reason": "Found no media in msn 2 of level \"https://schoolfighting.oss-cn-hangzhou.aliyuncs.com/test/teshh265/output.m3u8\"",
    "errorAction": {
        "action": 2,
        "flags": 1,
        "retryConfig": {
            "maxNumRetry": 6,
            "retryDelayMs": 1000,
            "maxRetryDelayMs": 8000
        },
        "retryCount": 2,
        "resolved": true
    }
}

Chrome media internals output

No response

@XiaoxiRao XiaoxiRao added Bug Needs Triage If there is a suspected stream issue, apply this label to triage if it is something we should fix. labels Dec 7, 2024
@XiaoxiRao
Copy link
Author

I tested this issue on the master branch.

@robwalch robwalch added Stream Issue and removed Bug labels Dec 12, 2024
@robwalch
Copy link
Collaborator

HLS.js does not support everything that VLC does. Please provide a better reason for triaging the included media.

The included error details suggest that the segments do not include media in a format supported by HLS.js. How was it encoded and packaged?

@XiaoxiRao
Copy link
Author

HLS.js does not support everything that VLC does. Please provide a better reason for triaging the included media.

The included error details suggest that the segments do not include media in a format supported by HLS.js. How was it encoded and packaged?

Thank you for your response. I believe the primary reason the stream fails to play is due to data loss in the video stream. However, I am not entirely sure about the root cause of the data loss. My role is simply to work with the given stream and ensure it plays correctly.

I did notice that when I commented out the line this.resetTransmuxer(); in the updateLevelTiming function within the base-stream-controller.ts class, the stream was able to play normally in hls.js. This leads me to believe that hls.js has the capability to handle this type of stream. However, its compatibility with certain erroneous streams could still be improved.

@robwalch
Copy link
Collaborator

robwalch commented Dec 15, 2024

HEVC in M2TS is a community contributed feature made up of these PRs (CC @devoldemar):

Provide more information about the asset encoding and packaging, including any identifiable out-of-spec features.

Try triaging the issue further in HLS.js. Why does HLS.js find no media in "6719b8152cdfb78408001bb7(1).ts" (set "enableWorker": false to debug through tsdemuxer)? It looks to me like this is an issue in the HevcVideoParser - The SPS and PPS are discarded when the VPS is not encountered first (skips everything in block requiringtrack.params to be an object):

// VPS
case 32:
push = true;
if (!track.vps) {
const config = this.readVPS(unit.data);
track.params = { ...config };
this.initVPS = unit.data;
}
track.vps = [unit.data];
break;

should probably be:

        // VPS
        case 32:
          push = true;
          track.params ||= {};
          Object.assign(track.params, this.readVPS(unit.data));
          this.initVPS = unit.data;
          track.vps = [unit.data];
          break;

Then

// SPS
case 33:
push = true;
spsfound = true;
if (typeof track.params === 'object') {
if (
track.vps !== undefined &&
track.vps[0] !== this.initVPS &&
track.sps !== undefined &&
!this.matchSPS(track.sps[0], unit.data)
) {
this.initVPS = track.vps[0];
track.sps = track.pps = undefined;
}
if (!track.sps) {

should always update track params (adding them if necessary)

        // SPS
        case 33:
          push = true;
          spsfound = true;
          if (
            track.vps !== undefined &&
            track.vps[0] !== this.initVPS &&
            track.sps !== undefined &&
            !this.matchSPS(track.sps[0], unit.data)
          ) {
            this.initVPS = track.vps[0];
            track.sps = track.pps = undefined;
          }
          if (!track.sps) {
            track.params ||= {};

And finally

// PPS
case 34:
push = true;
if (typeof track.params === 'object') {
if (!track.pps) {

should also always update track params (adding them if necessary)

        // PPS
        case 34:
          push = true;
          if (!track.pps) {
            track.params ||= {};

@robwalch robwalch added Needs contributor and removed Needs Triage If there is a suspected stream issue, apply this label to triage if it is something we should fix. labels Dec 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants