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

Playback fails when audio group has two renditions (aac, ac-3) #5378

Closed
5 tasks done
kmathewmk opened this issue Apr 7, 2023 · 11 comments
Closed
5 tasks done

Playback fails when audio group has two renditions (aac, ac-3) #5378

kmathewmk opened this issue Apr 7, 2023 · 11 comments
Labels
Bug Confirmed Bug report confirmed or reproduced. Stream Issue
Milestone

Comments

@kmathewmk
Copy link

What version of Hls.js are you using?

1.3.4

What browser (including version) are you using?

111.0.1661.62 (Official build) (64-bit)

What OS (including version) are you using?

Windows 10 Version 20H2 (Build 19042.2728)

Test stream

No response

Configuration

{
  "debug": true,
  "enableWorker": true,
  "lowLatencyMode": true,
  "backBufferLength": 90
}

Additional player setup steps

No response

Checklist

Steps to reproduce

  1. Extract content k.tar.gz to a http server
  2. Enter the URL into hls.js player and 'Apply'
  3. There is no playback and you should see the error reported below. Similar problem with v1.4.0-rc.1
  4. If the index.m3u8 is modified to have any one rendition in the audio group along with the corresponding change to the CODECS attribute, the playback if fine.

Expected behaviour

Playback is successful with the possibility of switching between the two renditions (aac and ac-3) in the audio group

What actually happened?

When I attempt to play the content, there is no playback

Status:
0.042 | Loading https://10.86.69.222/k/index.m3u8
0.053 | Loading manifest and attaching video element...
0.099 | Media element attached
0.212 | 1 quality levels found
0.213 | Manifest successfully loaded
0.218 | No of audio tracks found: 2
0.221 | Audio track switching...
0.633 | Audio track switched
0.679 | The video could not be loaded, either because the server or network failed or because the format is not supported - CHUNK_DEMUXER_ERROR_APPEND_FAILED: audio object type 0xa5 does not match what is specified in the mimetype.
Error:
0.662 | Buffer appending error
0.664 | Buffer append error
0.774 | Buffer append error
0.898 | Buffer append error
1.004 | Buffer append error

Console output

hlsjs.video-dev.org/:1 
        
       Unchecked runtime.lastError: The message port closed before a response was received.
hlsjs.video-dev.org/:1 
        
       Unchecked runtime.lastError: The message port closed before a response was received.
hlsjs.video-dev.org/:1 
        
       Unchecked runtime.lastError: The message port closed before a response was received.
hlsjs.video-dev.org/:1 
        
       Unchecked runtime.lastError: The message port closed before a response was received.
timeline-chart.ts:98 [Violation] Added non-passive event listener to a scroll-blocking 'wheel' event. Consider marking event handler as 'passive' to make the page more responsive. See https://www.chromestatus.com/feature/5745543795965952
TimelineChart @ timeline-chart.ts:98
setupTimelineChart @ main.js:1565
(anonymous) @ main.js:97
j @ jquery.min.js:2
fireWith @ jquery.min.js:2
ready @ jquery.min.js:2
I @ jquery.min.js:2
main.js:341 Using Hls.js config: {debug: true, enableWorker: true, lowLatencyMode: true, backBufferLength: 90}
logger.ts:74 [log] > Debug logs enabled for "Hls instance"
hls.ts:371 [log] > stopLoad
hls.ts:339 [log] > loadSource:https://10.86.69.222/k/index.m3u8
stream-controller.ts:550 [log] > [stream-controller]: Trigger BUFFER_RESET
hls.ts:310 [log] > attachMedia
buffer-controller.ts:791 [log] > [buffer-controller]: Media source opened
base-stream-controller.ts:1505 [log] > [subtitle-stream-controller]: STOPPED->IDLE
level-controller.ts:191 [log] > [level-controller]: manifest loaded, 1 level(s) found, first bitrate: 738738
buffer-controller.ts:142 [log] > 2 bufferCodec event(s) expected
hls.ts:361 [log] > startLoad(-1)
level-controller.ts:272 [log] > [level-controller]: switching to level 0 from -1
audio-track-controller.ts:134 [log] > [audio-track-controller]: Updating audio tracks, 2 track(s) found in "primary" group-id
audio-track-controller.ts:185 [log] > [audio-track-controller]: Now switching to audio-track index 1
base-stream-controller.ts:1505 [log] > [audio-stream-controller]: STOPPED->IDLE
base-stream-controller.ts:1505 [log] > [audio-stream-controller]: IDLE->WAITING_TRACK
level-controller.ts:584 [log] > [level-controller]: Attempt loading level index 0 with URL-id 0 https://10.86.69.222/k/v3-481.m3u8
base-stream-controller.ts:1505 [log] > [stream-controller]: STOPPED->IDLE
audio-track-controller.ts:259 [log] > [audio-track-controller]: loading audio-track playlist for id: 1
base-stream-controller.ts:1505 [log] > [audio-stream-controller]: WAITING_TRACK->STOPPED
base-stream-controller.ts:1505 [log] > [audio-stream-controller]: STOPPED->WAITING_TRACK
base-stream-controller.ts:1505 [log] > [subtitle-stream-controller]: IDLE->STOPPED
base-stream-controller.ts:1505 [log] > [subtitle-stream-controller]: STOPPED->IDLE
stream-controller.ts:615 [log] > [stream-controller]: Level 0 loaded [0,2], cc [0, 0] duration:9.009
buffer-controller.ts:683 [log] > [buffer-controller]: Updating Media Source duration to 9.009
base-stream-controller.ts:1273 [log] > [stream-controller]: Start time offset 0 found in playlist, adjust startPosition to 0
base-stream-controller.ts:660 [log] > [stream-controller]: Loading fragment initSegment cc: 0 of [0-2] level: 0, target: 0
base-stream-controller.ts:1505 [log] > [stream-controller]: IDLE->FRAG_LOADING
audio-track-controller.ts:87 [log] > [audio-track-controller]: audioTrack 1 loaded [0-2]
audio-stream-controller.ts:448 [log] > [audio-stream-controller]: Track 1 loaded [0,2],duration:9.009
base-stream-controller.ts:1273 [log] > [audio-stream-controller]: Start time offset 0 found in playlist, adjust startPosition to 0
base-stream-controller.ts:1505 [log] > [audio-stream-controller]: WAITING_TRACK->IDLE
base-stream-controller.ts:660 [log] > [audio-stream-controller]: Loading fragment initSegment cc: 0 of [0-2] track: 1, target: 0
base-stream-controller.ts:1505 [log] > [audio-stream-controller]: IDLE->FRAG_LOADING
base-stream-controller.ts:1505 [log] > [stream-controller]: FRAG_LOADING->IDLE
base-stream-controller.ts:504 [log] > [stream-controller]: Buffered main sn: initSegment of level 0 (frag:[NaN-NaN] > buffer:)
base-stream-controller.ts:660 [log] > [stream-controller]: Loading fragment 0 cc: 0 of [0-2] level: 0, target: 0
base-stream-controller.ts:1505 [log] > [stream-controller]: IDLE->FRAG_LOADING
base-stream-controller.ts:1505 [log] > [audio-stream-controller]: FRAG_LOADING->IDLE
base-stream-controller.ts:504 [log] > [audio-stream-controller]: Buffered audio sn: initSegment of track 1 (frag:[NaN-NaN] > buffer:)
base-stream-controller.ts:660 [log] > [audio-stream-controller]: Loading fragment 0 cc: 0 of [0-2] track: 1, target: 0
base-stream-controller.ts:1505 [log] > [audio-stream-controller]: IDLE->FRAG_LOADING
transmuxer-interface.ts:68 [log] > demuxing in webworker
transmuxer-interface.ts:201 [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
base-stream-controller.ts:371 [log] > [stream-controller]: Loaded fragment 0 of level 0
transmuxer-interface.ts:68 [log] > demuxing in webworker
audio-stream-controller.ts:555 [log] > [audio-stream-controller]: Unknown video PTS for cc 0, waiting for video PTS before demuxing audio frag 0 of [0 ,2],track 1
base-stream-controller.ts:1505 [log] > [audio-stream-controller]: FRAG_LOADING->WAITING_INIT_PTS
base-stream-controller.ts:371 [log] > [audio-stream-controller]: Loaded fragment 0 of level 1
6db9c29f-e6bc-41c7-9572-6757f857a36c:633 [log] > Debug logs enabled for "main"
base-stream-controller.ts:1505 [log] > [stream-controller]: FRAG_LOADING->PARSING
stream-controller.ts:1254 [log] > [stream-controller]: Init video buffer, container:video/mp4, codecs[level/parsed]=[avc1.4D401E/avc1.4D401E]
audio-stream-controller.ts:118 [log] > [audio-stream-controller]: InitPTS for cc: 0 found from main: 0
base-stream-controller.ts:1505 [log] > [audio-stream-controller]: WAITING_INIT_PTS->FRAG_LOADING
transmuxer-interface.ts:201 [log] > [transmuxer-interface, audio]: Starting new transmux session for sn: 0 p: -1 level: 1 id: 1
        discontinuity: true
        trackSwitch: true
        contiguous: false
        accurateTimeOffset: false
        timeOffset: 0
        initSegmentChange: true
transmuxer-interface.ts:349 [log] > [transmuxer.ts]: Flushed fragment 0 of level 0
base-stream-controller.ts:1505 [log] > [stream-controller]: PARSING->PARSED
b4f2f5c0-9f93-4ea0-844e-ad5cf9972563:633 [log] > Debug logs enabled for "audio"
base-stream-controller.ts:1505 [log] > [audio-stream-controller]: FRAG_LOADING->PARSING
audio-stream-controller.ts:854 [log] > [audio-stream-controller]: Switching audio track : flushing all audio
audio-stream-controller.ts:802 [log] > [audio-stream-controller]: Init audio buffer, container:audio/mp4, codecs[parsed]=[mp4a.40.2]
buffer-controller.ts:752 [log] > [buffer-controller]: creating sourceBuffer(video/mp4;codecs=avc1.4D401E)
buffer-controller.ts:752 [log] > [buffer-controller]: creating sourceBuffer(audio/mp4;codecs=mp4a.40.2)
stream-controller.ts:822 [log] > [stream-controller]: Alternate track found, use video.buffered to schedule main fragment loading
buffer-controller.ts:876 [log] > [buffer-controller]: Removing [0,9.009] from the audio SourceBuffer
transmuxer-interface.ts:349 [log] > [transmuxer.ts]: Flushed fragment 0 of level 1
base-stream-controller.ts:1505 [log] > [audio-stream-controller]: PARSING->PARSED
base-stream-controller.ts:504 [log] > [stream-controller]: Buffered main sn: 0 of level 0 (frag:[0.000-3.003] > buffer:[0.067-3.070])
base-stream-controller.ts:1505 [log] > [stream-controller]: PARSED->IDLE
base-stream-controller.ts:660 [log] > [stream-controller]: Loading fragment 1 cc: 0 of [0-2] level: 0, target: 3.07
base-stream-controller.ts:1505 [log] > [stream-controller]: IDLE->FRAG_LOADING
buffer-controller.ts:836 
        
       [error] > [buffer-controller]: audio SourceBuffer error Event {isTrusted: true, type: 'error', target: SourceBuffer, currentTarget: SourceBuffer, eventPhase: 2, …}
_onSBUpdateError @ buffer-controller.ts:836
error (async)
addBufferListener @ buffer-controller.ts:954
createSourceBuffers @ buffer-controller.ts:759
checkPendingTracks @ buffer-controller.ts:716
onBufferCodecs @ buffer-controller.ts:296
emit @ index.js:203
emit @ hls.ts:250
trigger @ hls.ts:258
_bufferInitSegment @ audio-stream-controller.ts:805
_handleTransmuxComplete @ audio-stream-controller.ts:729
handleTransmuxComplete @ transmuxer-interface.ts:377
onWorkerMessage @ transmuxer-interface.ts:337
main.js:725 
        
       Error event: {type: 'mediaError', details: 'bufferAppendingError', fatal: false}
(anonymous) @ main.js:725
emit @ index.js:203
emit @ hls.ts:250
trigger @ hls.ts:258
_onSBUpdateError @ buffer-controller.ts:839
error (async)
addBufferListener @ buffer-controller.ts:954
createSourceBuffers @ buffer-controller.ts:759
checkPendingTracks @ buffer-controller.ts:716
onBufferCodecs @ buffer-controller.ts:296
emit @ index.js:203
emit @ hls.ts:250
trigger @ hls.ts:258
_bufferInitSegment @ audio-stream-controller.ts:805
_handleTransmuxComplete @ audio-stream-controller.ts:729
handleTransmuxComplete @ transmuxer-interface.ts:377
onWorkerMessage @ transmuxer-interface.ts:337
buffer-controller.ts:409 
        
       [error] > [buffer-controller]: Error encountered while trying to append to the audio SourceBuffer Event {isTrusted: true, type: 'error', target: SourceBuffer, currentTarget: SourceBuffer, eventPhase: 2, …}
onError @ buffer-controller.ts:409
_onSBUpdateError @ buffer-controller.ts:847
error (async)
addBufferListener @ buffer-controller.ts:954
createSourceBuffers @ buffer-controller.ts:759
checkPendingTracks @ buffer-controller.ts:716
onBufferCodecs @ buffer-controller.ts:296
emit @ index.js:203
emit @ hls.ts:250
trigger @ hls.ts:258
_bufferInitSegment @ audio-stream-controller.ts:805
_handleTransmuxComplete @ audio-stream-controller.ts:729
handleTransmuxComplete @ transmuxer-interface.ts:377
onWorkerMessage @ transmuxer-interface.ts:337
main.js:725 
        
       Error event: {type: 'mediaError', parent: 'audio', details: 'bufferAppendError', err: Event, fatal: false}
(anonymous) @ main.js:725
emit @ index.js:203
emit @ hls.ts:250
trigger @ hls.ts:258
onError @ buffer-controller.ts:439
_onSBUpdateError @ buffer-controller.ts:847
error (async)
addBufferListener @ buffer-controller.ts:954
createSourceBuffers @ buffer-controller.ts:759
checkPendingTracks @ buffer-controller.ts:716
onBufferCodecs @ buffer-controller.ts:296
emit @ index.js:203
emit @ hls.ts:250
trigger @ hls.ts:258
_bufferInitSegment @ audio-stream-controller.ts:805
_handleTransmuxComplete @ audio-stream-controller.ts:729
handleTransmuxComplete @ transmuxer-interface.ts:377
onWorkerMessage @ transmuxer-interface.ts:337
buffer-controller.ts:810 [log] > [buffer-controller]: Media source ended
main.js:1005 
        
       The video could not be loaded, either because the server or network failed or because the format is not supported - CHUNK_DEMUXER_ERROR_APPEND_FAILED: audio object type 0xa5 does not match what is specified in the mimetype.
handleVideoEvent @ main.js:1005
error (async)
addVideoEventListeners @ main.js:929
loadSelectedStream @ main.js:372
(anonymous) @ main.js:227
j @ jquery.min.js:2
fireWith @ jquery.min.js:2
ready @ jquery.min.js:2
I @ jquery.min.js:2
buffer-helper.ts:174 [log] > failed to get media.buffered DOMException: Failed to read the 'buffered' property from 'SourceBuffer': This SourceBuffer has been removed from the parent media source.
    at Function.getBuffered (https://hlsjs.video-dev.org/dist/hls.js:21223:20)
    at Object.onComplete (https://hlsjs.video-dev.org/dist/hls.js:3390:94)
    at BufferController._onSBUpdateEnd (https://hlsjs.video-dev.org/dist/hls.js:3732:15)
buffer-helper.ts:174 [log] > failed to get media.buffered DOMException: Failed to read the 'buffered' property from 'SourceBuffer': This SourceBuffer has been removed from the parent media source.
    at Function.getBuffered (https://hlsjs.video-dev.org/dist/hls.js:21223:20)
    at Object.onComplete (https://hlsjs.video-dev.org/dist/hls.js:3390:94)
    at BufferController._onSBUpdateEnd (https://hlsjs.video-dev.org/dist/hls.js:3732:15)
buffer-helper.ts:174 [log] > failed to get media.buffered DOMException: Failed to read the 'buffered' property from 'SourceBuffer': This SourceBuffer has been removed from the parent media source.
    at Function.getBuffered (https://hlsjs.video-dev.org/dist/hls.js:21223:20)
    at AudioStreamController.fragBufferedComplete (https://hlsjs.video-dev.org/dist/hls.js:2284:520)
    at AudioStreamController.onFragBuffered (https://hlsjs.video-dev.org/dist/hls.js:1194:10)
    at EventEmitter.emit (https://hlsjs.video-dev.org/dist/hls.js:26512:33)
    at Hls.emit (https://hlsjs.video-dev.org/dist/hls.js:15508:26)
    at Hls.trigger (https://hlsjs.video-dev.org/dist/hls.js:15512:19)
    at onUnblocked (https://hlsjs.video-dev.org/dist/hls.js:3484:18)
    at https://hlsjs.video-dev.org/dist/hls.js:3817:7
base-stream-controller.ts:504 [log] > [audio-stream-controller]: Buffered audio sn: 0 of track 1 (frag:[0.097-3.073] > buffer:)
base-stream-controller.ts:1505 [log] > [audio-stream-controller]: PARSED->IDLE
buffer-helper.ts:174 [log] > failed to get media.buffered DOMException: Failed to read the 'buffered' property from 'SourceBuffer': This SourceBuffer has been removed from the parent media source.
    at Function.getBuffered (https://hlsjs.video-dev.org/dist/hls.js:21223:20)
    at AudioStreamController.afterBufferFlushed (https://hlsjs.video-dev.org/dist/hls.js:2920:93)
    at AudioStreamController.doTickIdle (https://hlsjs.video-dev.org/dist/hls.js:937:12)
    at AudioStreamController.doTick (https://hlsjs.video-dev.org/dist/hls.js:816:14)
    at AudioStreamController.tick (https://hlsjs.video-dev.org/dist/hls.js:20600:12)
    at AudioStreamController.fragBufferedComplete (https://hlsjs.video-dev.org/dist/hls.js:2293:10)
    at AudioStreamController.onFragBuffered (https://hlsjs.video-dev.org/dist/hls.js:1194:10)
    at EventEmitter.emit (https://hlsjs.video-dev.org/dist/hls.js:26512:33)
    at Hls.emit (https://hlsjs.video-dev.org/dist/hls.js:15508:26)
    at Hls.trigger (https://hlsjs.video-dev.org/dist/hls.js:15512:19)
buffer-helper.ts:174 [log] > failed to get media.buffered DOMException: Failed to read the 'buffered' property from 'SourceBuffer': This SourceBuffer has been removed from the parent media source.
    at Function.getBuffered (https://hlsjs.video-dev.org/dist/hls.js:21223:20)
    at Function.bufferInfo (https://hlsjs.video-dev.org/dist/hls.js:21123:38)
    at AudioStreamController.getFwdBufferInfo (https://hlsjs.video-dev.org/dist/hls.js:2562:85)
    at AudioStreamController.doTickIdle (https://hlsjs.video-dev.org/dist/hls.js:939:27)
    at AudioStreamController.doTick (https://hlsjs.video-dev.org/dist/hls.js:816:14)
    at AudioStreamController.tick (https://hlsjs.video-dev.org/dist/hls.js:20600:12)
    at AudioStreamController.fragBufferedComplete (https://hlsjs.video-dev.org/dist/hls.js:2293:10)
    at AudioStreamController.onFragBuffered (https://hlsjs.video-dev.org/dist/hls.js:1194:10)
    at EventEmitter.emit (https://hlsjs.video-dev.org/dist/hls.js:26512:33)
    at Hls.emit (https://hlsjs.video-dev.org/dist/hls.js:15508:26)

Chrome media internals output

No response

@kmathewmk kmathewmk added Bug Needs Triage If there is a suspected stream issue, apply this label to triage if it is something we should fix. labels Apr 7, 2023
@robwalch robwalch added Missing Feature and removed Bug Needs Triage If there is a suspected stream issue, apply this label to triage if it is something we should fix. labels Apr 7, 2023
@robwalch robwalch added this to the 1.5.0 milestone Apr 7, 2023
@robwalch robwalch added Bug Confirmed Bug report confirmed or reproduced. labels Apr 7, 2023
@robwalch
Copy link
Collaborator

robwalch commented Apr 7, 2023

As of v1.4 HLS.js does not handle audio groups with multiple codecs (it can handle some in track changes at DISCONTINUITY for SSAI streams).

HLS.js initializes audio source buffers based on preferred codecs, so mp4a.40.2 in this case when CODECS="avc1.4D401E,mp4a.40.2,ac-3":

var preferred = filtered.filter(function (codec) {
  return codec.lastIndexOf('avc1', 0) === 0 || codec.lastIndexOf('mp4a', 0) === 0;
});

There is no way to tell which media options uses which codec (other than guessing based on CHANNELS) so generally the authoring guidelines are to split these into different variants and groups. That way, clients without ac-3 support can still select variants with the aac group, and ac-3 playback is achieved by changing variants to the one(s) using the multi-channel group. This Multivariant Playlist does play in HLS.js, with both supported renditions selectable through hls.levels in Safari:

#EXTM3U
#EXT-X-VERSION:6
#EXT-X-INDEPENDENT-SEGMENTS
#EXT-X-MEDIA:TYPE=AUDIO,GROUP-ID="aac",NAME="UND-aac",DEFAULT=YES,AUTOSELECT=NO,LANGUAGE="und",CHANNELS="2",URI="v3-483.m3u8"
#EXT-X-MEDIA:TYPE=AUDIO,GROUP-ID="ac3",NAME="UND-ac3",DEFAULT=YES,AUTOSELECT=NO,LANGUAGE="und",CHANNELS="6",URI="v3-482.m3u8"
#EXT-X-STREAM-INF:BANDWIDTH=812000,AVERAGE-BANDWIDTH=738100,RESOLUTION=480x270,CODECS="avc1.4D401E,mp4a.40.2",FRAME-RATE=29.970,AUDIO="aac",CLOSED-CAPTIONS=NONE
v3-481.m3u8
#EXT-X-STREAM-INF:BANDWIDTH=812611,AVERAGE-BANDWIDTH=738738,RESOLUTION=480x270,CODECS="avc1.4D401E,ac-3",FRAME-RATE=29.970,AUDIO="ac3",CLOSED-CAPTIONS=NONE
v3-481.m3u8

We'll look to handle multiple codecs in the same audio group properly in v1.5. For 1.4.x the best we could do is patch the player to force stereo selection on start, as multichannel support is is incomplete.

You should list ac-3 first if that is the default track (NAME="UND-ac3",DEFAULT=YES so CODECS="avc1.4D401E,ac-3,mp4a.40.2"). This won't make a difference in HLS.js for now, but in future releases we could and should start with the first video and audio codec listed in CODECS, if not ignore this order completely and defer SB initialization until media is parsed (this however would only delay startup).

@kmathewmk
Copy link
Author

kmathewmk commented Apr 8, 2023

so generally the authoring guidelines are to split these into different variants and groups. That way, clients without ac-3 support can still select variants with the aac group, and ac-3 playback is achieved by changing variants to the one(s) using the multi-channel group.

I tried this first in Edge but ran into the error below when switching to AAC audio. Playback starts correctly with AC-3.

Error:
9.512 | A media error occurred: audioTrackLoadError
Status:
7.813 | Media element detached
7.821 | Loading https://10.86.69.222/k/index-2ag.m3u8
7.823 | Loading manifest and attaching video element...
7.838 | Media element attached
7.874 | 2 quality levels found
7.874 | Manifest successfully loaded
7.876 | No of audio tracks found: 1
7.878 | Audio track switching...
8.182 | Audio track switched
9.507 | No of audio tracks found: 1, trying to recover media error.
9.517 | Media element detached
9.558 | Media element attached

image
The multivariant playlist index-2ag.m3u8 was used

#EXTM3U
#EXT-X-VERSION:6
#EXT-X-INDEPENDENT-SEGMENTS
#EXT-X-MEDIA:TYPE=AUDIO,GROUP-ID="ac3",NAME="UND-ac3",DEFAULT=YES,AUTOSELECT=NO,LANGUAGE="und",CHANNELS="6",URI="v3-482.m3u8"
#EXT-X-MEDIA:TYPE=AUDIO,GROUP-ID="aac",NAME="UND-aac",DEFAULT=YES,AUTOSELECT=NO,LANGUAGE="und",CHANNELS="2",URI="v3-483.m3u8"
#EXT-X-STREAM-INF:BANDWIDTH=812611,AVERAGE-BANDWIDTH=738738,RESOLUTION=480x270,CODECS="avc1.4D401E,ac-3",FRAME-RATE=29.970,AUDIO="ac3",CLOSED-CAPTIONS=NONE
v3-481.m3u8
#EXT-X-STREAM-INF:BANDWIDTH=812611,AVERAGE-BANDWIDTH=738738,RESOLUTION=480x270,CODECS="avc1.4D401E,mp4a.40.2",FRAME-RATE=29.970,AUDIO="aac",CLOSED-CAPTIONS=NONE
v3-481.m3u8

Console logs: index-2ag-hlsjs.video-dev.org.log

I guess this should be treated as a different bug/issue.

In Chrome 112.0.5615.49 (Official Build) (64-bit) (cohort: M112_Early_Stable_Rampup), playback starts correctly with AAC since AC-3 decoding is not supported.

@robwalch
Copy link
Collaborator

robwalch commented Jun 1, 2023

Hi @kmathewmk,

I'd like to know if #5528 resolves this issue for you. Can you give it a try? If not can you provide a sample stream that can be used to reproduce the issue? Thanks!

@kmathewmk
Copy link
Author

I guess the sample in k.tar.gz should suffice. Extract content to a http server and play the URL https:///k/index.m3u8

@robwalch
Copy link
Collaborator

robwalch commented Jun 1, 2023

I guess the sample in k.tar.gz should suffice. Extract content to a http server and play the URL https:///k/index.m3u8

Thanks @kmathewmk,

There is still some work to do:

  • Filter variants with any unsupported codecs #5533
    • HLS.js should not play variants for which it does not support all codecs (so if Chrome for example does not support AC3, it should not play this variant, because it requires support for both AAC and AC3)
    • Assign each parsed audio init segments codec to its corresponding track (so that the MSE audio SourceBuffer is initialized with the correct type, and changeType is used when the appended type changes)
  • API enhancements for audio (and subtitle) track selection #5532; by language and features such as number of channels or description

@robwalch
Copy link
Collaborator

robwalch commented Jun 1, 2023

HLS.js should not play variants for which it does not support all codecs (so if Chrome for example does not support AC3, it should not play this stream, because it requires support for both AAC and AC3)

#EXT-X-MEDIA:TYPE=AUDIO,GROUP-ID="primary",NAME="UND-aac",DEFAULT=NO,AUTOSELECT=NO,LANGUAGE="und",CHANNELS="2",URI="v3-483.m3u8"
#EXT-X-MEDIA:TYPE=AUDIO,GROUP-ID="primary",NAME="UND-ac3",DEFAULT=YES,AUTOSELECT=NO,LANGUAGE="und",CHANNELS="6",URI="v3-482.m3u8"
#EXT-X-STREAM-INF:BANDWIDTH=812611,AVERAGE-BANDWIDTH=738738,RESOLUTION=480x270,CODECS="avc1.4D401E,mp4a.40.2,ac-3",FRAME-RATE=29.970,AUDIO="primary",CLOSED-CAPTIONS=NONE
v3-481.m3u8

On this point, if you want browsers to select the supported audio, and ignore unsupported audio, you should supply two variants, one for each media option with LANGUAGE and NAME matching, indicating that these are alternates of each other:

#EXT-X-MEDIA:TYPE=AUDIO,GROUP-ID="primary-aac",NAME="English",DEFAULT=NO,AUTOSELECT=NO,LANGUAGE="en",CHANNELS="2",URI="v3-483.m3u8"
#EXT-X-MEDIA:TYPE=AUDIO,GROUP-ID="primary-ac3",NAME="English",DEFAULT=YES,AUTOSELECT=YES,LANGUAGE="en",CHANNELS="4",URI="v3-482.m3u8"
#EXT-X-STREAM-INF:BANDWIDTH=525312,AVERAGE-BANDWIDTH=525312,RESOLUTION=480x270,CODECS="avc1.4D401E,mp4a.40.2",FRAME-RATE=29.970,AUDIO="primary-aac",CLOSED-CAPTIONS=NONE
v3-481.m3u8
#EXT-X-STREAM-INF:BANDWIDTH=729600,AVERAGE-BANDWIDTH=729600,RESOLUTION=480x270,CODECS="avc1.4D401E,ac-3",FRAME-RATE=29.970,AUDIO="primary-ac3",CLOSED-CAPTIONS=NONE
v3-481.m3u8

Otherwise, what should happen, is if any of the CODECS are not supported, HLS.js will filter out the variant - refusing to play it - and erroring if all were filtered out. While you could use a different name for each, it is the clients responsibility (using CHANNELS and other attributes) to distinguish the differences between each option.

@kmathewmk
Copy link
Author

Even with two audio groups (one aac and another ac-3) playback did not work. Please see my Apr 8 comment for details/logs. The multivariant playlist used was index-2ag.m3u8:

#EXTM3U
#EXT-X-VERSION:6
#EXT-X-INDEPENDENT-SEGMENTS
#EXT-X-MEDIA:TYPE=AUDIO,GROUP-ID="ac3",NAME="UND-ac3",DEFAULT=YES,AUTOSELECT=NO,LANGUAGE="und",CHANNELS="6",URI="v3-482.m3u8"
#EXT-X-MEDIA:TYPE=AUDIO,GROUP-ID="aac",NAME="UND-aac",DEFAULT=YES,AUTOSELECT=NO,LANGUAGE="und",CHANNELS="2",URI="v3-483.m3u8"
#EXT-X-STREAM-INF:BANDWIDTH=812611,AVERAGE-BANDWIDTH=738738,RESOLUTION=480x270,CODECS="avc1.4D401E,ac-3",FRAME-RATE=29.970,AUDIO="ac3",CLOSED-CAPTIONS=NONE
v3-481.m3u8
#EXT-X-STREAM-INF:BANDWIDTH=812611,AVERAGE-BANDWIDTH=738738,RESOLUTION=480x270,CODECS="avc1.4D401E,mp4a.40.2",FRAME-RATE=29.970,AUDIO="aac",CLOSED-CAPTIONS=NONE
v3-481.m3u8

If the above playlist was tweaked by changing one bitrate to 812612 to have non-identical bitrates, playback works. The multivariant playlist used was index-2ag-2br.m3u8:

#EXTM3U
#EXT-X-VERSION:6
#EXT-X-INDEPENDENT-SEGMENTS
#EXT-X-MEDIA:TYPE=AUDIO,GROUP-ID="ac3",NAME="UND-ac3",DEFAULT=YES,AUTOSELECT=NO,LANGUAGE="und",CHANNELS="6",URI="v3-482.m3u8"
#EXT-X-MEDIA:TYPE=AUDIO,GROUP-ID="aac",NAME="UND-aac",DEFAULT=YES,AUTOSELECT=NO,LANGUAGE="und",CHANNELS="2",URI="v3-483.m3u8"
#EXT-X-STREAM-INF:BANDWIDTH=812612,AVERAGE-BANDWIDTH=738738,RESOLUTION=480x270,CODECS="avc1.4D401E,ac-3",FRAME-RATE=29.970,AUDIO="ac3",CLOSED-CAPTIONS=NONE
v3-481.m3u8
#EXT-X-STREAM-INF:BANDWIDTH=812611,AVERAGE-BANDWIDTH=738738,RESOLUTION=480x270,CODECS="avc1.4D401E,mp4a.40.2",FRAME-RATE=29.970,AUDIO="aac",CLOSED-CAPTIONS=NONE
v3-481.m3u8

@robwalch
Copy link
Collaborator

robwalch commented Jun 5, 2023

If the above playlist was tweaked by changing one bitrate to 812612 to have non-identical bitrates, playback works.

That could be because you are using v1.3 which identifies variants with the same bitrate and resolution as redundant.

v1.4 recognizes these variants as unique when CODECS does not match as well. However, the BANDWIDTH should be different as it should include the audio bitrate which is unlikely to match exactly between audio renditions.

@robwalch
Copy link
Collaborator

Hi @kmathewmk,

Are you still experiencing this issue in dev https://hlsjs-dev.video-dev.org/demo/ ?

@kmathewmk
Copy link
Author

I tested with hls.js 1.4.10 and index-2ag.m3u8 having two audio tracks with identical bitrate works now. On a Windows PC, Chrome plays AAC and Edge plays AC-3

8.124 | Media element detached
8.129 | Loading https://h40.envivio.com/k/index-2ag.m3u8
8.134 | Loading manifest and attaching video element...
8.145 | Media element attached
8.618 | 1 quality levels found
8.618 | Manifest successfully loaded
8.619 | No of audio tracks found: 1
8.62 | Audio track switching...
9.224 | Audio track switched

@robwalch
Copy link
Collaborator

Sounds like the issue is resolved then. If you can, please check dev - 1.4.11-canary or "dev" is the closest thiong we have to a prerelease for v1.5.0 at the moment. A beta for v1.5.0 will be released once all feature-related issues with milestone 1.5.0 have been resolved.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Confirmed Bug report confirmed or reproduced. Stream Issue
Projects
None yet
Development

No branches or pull requests

2 participants