video-dev / hls.js

HLS.js is a JavaScript library that plays HLS in browsers with support for MSE.
https://hlsjs.video-dev.org/demo
Other
14.78k stars 2.57k forks source link

The steering mechanism does not work as expected #6759

Closed cheluskin closed 5 days ago

cheluskin commented 6 days ago

What do you want to do with Hls.js?

The steering mechanism does not work as expected. I have a primary server and a failback server.

{
  "VERSION": 1,
  "TTL": 72000,
  "PATHWAY-PRIORITY": [".", "FAILBACK"],
  "PATHWAY-CLONES": [
    {
      "ID": "FAILBACK",
      "BASE-ID": ".",
      "URI-REPLACEMENT": {
        "HOST": "failback.armdb.org"
      }
    }
  ]
}

My understanding is that if there are no errors, it should not switch to failback. But now it switches from level 0 to level 3 and requests go to failback all the time. I think the problem is related to level switching. For some unknown reason the standard level switching leads to switching to a PATHWAY-ID with a lower priority

hls.js@latest:1 [log] > Debug logs enabled for "Hls instance" in hls.js version 1.5.15
hls.js@latest:1 [log] > stopLoad
hls.js@latest:1 [log] > loadSource:https://hls.armdb.org/file/armdb-hls/videos/82905-test/p.m3u8?test=13
hls.js@latest:1 [log] > [stream-controller]: Trigger BUFFER_RESET
hls.js@latest:1 [log] > attachMedia
hls.js@latest:1 [log] > [buffer-controller] created media source: MediaSource
hls.js@latest:1 [log] > startLoad(-1)
hls.js@latest:1 [log] > [subtitle-stream-controller]: STOPPED->IDLE
hls.js@latest:1 [log] > [buffer-controller] Media source opened
hls.js@latest:1 [log] > [content-steering]: Requesting steering manifest: data:application/vndapplesteering-list;charset=utf-8;base64,eyJWRVJTSU9OIjoxLCJUVEwiOjcyMDAwLCJQQVRIV0FZLVBSSU9SSVRZIjpbIi4iLCJGQUlMQkFDSyJdLCJQQVRIV0FZLUNMT05FUyI6W3siQkFTRS1JRCI6Ii4iLCJJRCI6IkZBSUxCQUNLIiwiVVJJLVJFUExBQ0VNRU5UIjp7IkhPU1QiOiJmYWlsYmFjay5hcm1kYi5vcmcifX1dfQ==
hls.js@latest:1 [log] > [level-controller]: manifest loaded, 2 level(s) found, first bitrate: 690800
hls.js@latest:1 [log] > setting initial bwe to 690800
hls.js@latest:1 [log] > [buffer-controller] 1 bufferCodec event(s) expected
hls.js@latest:1 [log] > startLoad(-1)
hls.js@latest:1 [log] > [content-steering]: Requesting steering manifest: data:application/vndapplesteering-list;charset=utf-8;base64,eyJWRVJTSU9OIjoxLCJUVEwiOjcyMDAwLCJQQVRIV0FZLVBSSU9SSVRZIjpbIi4iLCJGQUlMQkFDSyJdLCJQQVRIV0FZLUNMT05FUyI6W3siQkFTRS1JRCI6Ii4iLCJJRCI6IkZBSUxCQUNLIiwiVVJJLVJFUExBQ0VNRU5UIjp7IkhPU1QiOiJmYWlsYmFjay5hcm1kYi5vcmcifX1dfQ==
hls.js@latest:1 [log] > [abr] picked start tier {"codecSet":"avc1,mp4a","videoRanges":["SDR"],"preferHDR":false,"minFramerate":25,"minBitrate":690800}
hls.js@latest:1 [info] > [abr] switch candidate:0->0 adjustedbw(690800)-bitrate=0 ttfb:0.1 avgDuration:0.0 maxFetchDuration:4.0 fetchDuration:0.1 firstSelection:true codecSet:avc1,mp4a videoRange:SDR hls.loadLevel:-1
hls.js@latest:1 [log] > [level-controller]: Switching to level 0 (720p SDR avc1,mp4a @690800) from level -1
hls.js@latest:1 [log] > [level-controller]: Loading level index 0 with https://hls.armdb.org/file/armdb-hls/videos/82905-test/p_0.m3u8
hls.js@latest:1 [log] > [stream-controller]: STOPPED->IDLE
hls.js@latest:1 [log] > [subtitle-stream-controller]: IDLE->STOPPED
hls.js@latest:1 [log] > [subtitle-stream-controller]: STOPPED->IDLE
hls.js@latest:1 [log] > [content-steering]: Loaded steering manifest: "data:application/vndapplesteering-list;charset=utf-8;base64,eyJWRVJTSU9OIjoxLCJUVEwiOjcyMDAwLCJQQVRIV0FZLVBSSU9SSVRZIjpbIi4iLCJGQUlMQkFDSyJdLCJQQVRIV0FZLUNMT05FUyI6W3siQkFTRS1JRCI6Ii4iLCJJRCI6IkZBSUxCQUNLIiwiVVJJLVJFUExBQ0VNRU5UIjp7IkhPU1QiOiJmYWlsYmFjay5hcm1kYi5vcmcifX1dfQ=="
hls.js@latest:1 [log] > [stream-controller]: Level 0 loaded [0,3][part-3--1], cc [0, 0] duration:64.44
hls.js@latest:1 [log] > [buffer-controller] Updating Media Source duration to 64.440
hls.js@latest:1 [log] > [stream-controller]: Loading fragment 0 cc: 0 of [0-3] level: 0, target: 0
hls.js@latest:1 [log] > [stream-controller]: IDLE->FRAG_LOADING
hls.js@latest:1 [log] > [transmuxer-interface, main]: Starting new transmux session for sn: 0 p: -1 level: 0 id: 1
        discontinuity: true
        trackSwitch: true
        contiguous: false
        accurateTimeOffset: true
        timeOffset: 0
        initSegmentChange: true
hls.js@latest:1 [log] > [mp4-remuxer]: ISGenerated flag reset
hls.js@latest:1 [log] > [mp4-remuxer]: initPTS & initDTS reset
hls.js@latest:1 [log] > [mp4-remuxer]: reset next timestamp
hls.js@latest:1 [log] > manifest codec:mp4a.40.2, ADTS type:2, samplingIndex:4
hls.js@latest:1 [log] > parsed codec:mp4a.40.5, rate:44100, channels:2
hls.js@latest:1 [log] > [stream-controller]: FRAG_LOADING->PARSING
hls.js@latest:1 [log] > [stream-controller]: Init audio buffer, container:audio/mp4, codecs[selected/level/parsed]=[mp4a.40.2/mp4a.40.2/mp4a.40.5]
hls.js@latest:1 [log] > [stream-controller]: Init video buffer, container:video/mp4, codecs[level/parsed]=[avc1.64001f/avc1.64001f]
hls.js@latest:1 [log] > [buffer-controller] 0 bufferCodec event(s) expected audio,video
hls.js@latest:1 [log] > [buffer-controller] creating sourceBuffer(audio/mp4;codecs=mp4a.40.2)
hls.js@latest:1 [log] > [buffer-controller] creating sourceBuffer(video/mp4;codecs=avc1.64001f)
hls.js@latest:1 [log] > [audio-stream-controller]: InitPTS for cc: 0 found from main: 131110
hls.js@latest:1 [log] > [stream-controller]: Loaded fragment 0 of level 0
hls.js@latest:1 [log] > [transmuxer.ts]: Flushed fragment 0 of level 0
hls.js@latest:1 [log] > [stream-controller]: PARSING->PARSED
hls.js@latest:1 [log] > [stream-controller]: Buffered main sn: 0 of level 0 (frag:[0.000-21.143] > buffer:[0.023-21.084])
hls.js@latest:1 [log] > [stream-controller]: PARSED->IDLE
hls.js@latest:1 [info] > [abr] switch candidate:0->3 adjustedbw(33399786)-bitrate=31278986 ttfb:0.5 avgDuration:21.1 maxFetchDuration:21.1 fetchDuration:1.9 firstSelection:false codecSet:avc1,mp4a videoRange:SDR hls.loadLevel:0
hls.js@latest:1 [log] > [stream-controller]: Adapting to level 3 from level 0
hls.js@latest:1 [log] > [level-controller]: Switching to level 3 (720p SDR avc1,mp4a @2120800) with Pathway FAILBACK from level 0
hls.js@latest:1 [log] > [level-controller]: Loading level index 3 with Pathway FAILBACK https://failback.armdb.org/file/armdb-hls/videos/82905-test/p_1.m3u8
hls.js@latest:1 [log] > [stream-controller]: IDLE->WAITING_LEVEL
hls.js@latest:1 [info] > [abr] buffer is empty, optimal quality level 3
hls.js@latest:1 [log] > [stream-controller]: media seeking to 21.439, state: WAITING_LEVEL
hls.js@latest:1 [log] > [audio-stream-controller]: media seeking to 21.439, state: STOPPED
hls.js@latest:1 [log] > [subtitle-stream-controller]: media seeking to 21.439, state: IDLE
hls.js@latest:1 [info] > [abr] buffer is empty, optimal quality level 3
hls.js@latest:1 [info] > [abr] buffer is empty, optimal quality level 3
hls.js@latest:1 [log] > [stream-controller]: Level 3 loaded [0,3][part-3--1], cc [0, 0] duration:64.44
hls.js@latest:1 [log] > [stream-controller]: WAITING_LEVEL->IDLE
hls.js@latest:1 [info] > [abr] buffer is empty, optimal quality level 3
hls.js@latest:1 [log] > [stream-controller]: Loading fragment 1 cc: 0 of [0-3] level: 3, target: 21.439
hls.js@latest:1 [log] > [stream-controller]: IDLE->FRAG_LOADING
hls.js@latest:1 [log] > [transmuxer-interface, main]: Starting new transmux session for sn: 1 p: -1 level: 3 id: 1
        discontinuity: false
        trackSwitch: true
        contiguous: false
        accurateTimeOffset: true
        timeOffset: 21.12
        initSegmentChange: false
hls.js@latest:1 [log] > [mp4-remuxer]: ISGenerated flag reset
hls.js@latest:1 [log] > [mp4-remuxer]: initPTS & initDTS reset
hls.js@latest:1 [log] > [mp4-remuxer]: reset next timestamp
hls.js@latest:1 [log] > manifest codec:mp4a.40.2, ADTS type:2, samplingIndex:4
hls.js@latest:1 [log] > parsed codec:mp4a.40.5, rate:44100, channels:2
hls.js@latest:1 [log] > [stream-controller]: FRAG_LOADING->PARSING
hls.js@latest:1 [log] > [stream-controller]: Init audio buffer, container:audio/mp4, codecs[selected/level/parsed]=[mp4a.40.2/mp4a.40.2/mp4a.40.5]
hls.js@latest:1 [log] > [stream-controller]: Init video buffer, container:video/mp4, codecs[level/parsed]=[avc1.64001f/avc1.64001f]
hls.js@latest:1 [log] > [buffer-controller] changing audio sourceBuffer type to audio/mp4;codecs=mp4a.40.5
hls.js@latest:1 [log] > [buffer-controller] switching codec mp4a.40.2 to mp4a.40.5
hls.js@latest:1 [log] > [stream-controller]: Loaded fragment 1 of level 3
hls.js@latest:1 [log] > [transmuxer.ts]: Flushed fragment 1 of level 3
hls.js@latest:1 [log] > [stream-controller]: PARSING->PARSED
hls.js@latest:1 [log] > [stream-controller]: Buffered main sn: 1 of level 3 (frag:[21.084-40.343] > buffer:[0.023-40.263])
hls.js@latest:1 [log] > [stream-controller]: PARSED->IDLE
hls.js@latest:1 [log] > [stream-controller]: Loading fragment 2 cc: 0 of [0-3] level: 3, target: 40.263
hls.js@latest:1 [log] > [stream-controller]: IDLE->FRAG_LOADING
hls.js@latest:1 [log] > [stream-controller]: Media seeked to 21.439
hls.js@latest:1 [log] > [stream-controller]: FRAG_LOADING->PARSING
hls.js@latest:1 [log] > [stream-controller]: Loaded fragment 2 of level 3
hls.js@latest:1 [log] > [transmuxer.ts]: Flushed fragment 2 of level 3
hls.js@latest:1 [log] > [stream-controller]: PARSING->PARSED
hls.js@latest:1 [log] > [stream-controller]: Buffered main sn: 2 of level 3 (frag:[40.263-61.463] > buffer:[0.023-61.394])
hls.js@latest:1 [log] > [stream-controller]: PARSED->IDLE
hls.js@latest:1 [log] > [stream-controller]: Loading fragment 3 cc: 0 of [0-3] level: 3, target: 61.394
hls.js@latest:1 [log] > [stream-controller]: IDLE->FRAG_LOADING
hls.js@latest:1 [log] > [stream-controller]: FRAG_LOADING->PARSING
hls.js@latest:1 [log] > [stream-controller]: Loaded fragment 3 of level 3
hls.js@latest:1 [log] > [transmuxer.ts]: Flushed fragment 3 of level 3
hls.js@latest:1 [log] > [stream-controller]: PARSING->PARSED
hls.js@latest:1 [log] > [stream-controller]: Buffered main sn: 3 of level 3 (frag:[61.394-64.528] > buffer:[0.023-64.463])
hls.js@latest:1 [log] > [stream-controller]: PARSED->IDLE
hls.js@latest:1 [log] > [buffer-controller] audio sourceBuffer now EOS
hls.js@latest:1 [log] > [buffer-controller] video sourceBuffer now EOS
hls.js@latest:1 [log] > [buffer-controller] Queueing mediaSource.endOfStream()
hls.js@latest:1 [log] > [stream-controller]: IDLE->ENDED
hls.js@latest:1 [log] > [buffer-controller] Calling mediaSource.endOfStream()
hls.js@latest:1 [log] > [buffer-controller] Media source ended
index.php:1 Specifying 'overflow: visible' on img, video and canvas tags may cause them to produce visual content outside of the element bounds. See https://github.com/WICG/view-transitions/blob/main/debugging_overflow_on_images.md for details.

What have you tried so far?

No response

robwalch commented 6 days ago

It looks like we have a bug related to starting off with a single default pathway and cloning. If there aren't pathways to filter out other than the default, or the pathway is not explicitly changed on start, then the levels array in the level controller remain the same as that in the content-steering controller.

Here's a fix for the issue: