Can't handle when stream comes in with no audio track
What version of Hls.js are you using?
1.0.7
What browser (including version) are you using?
Chrome Version 99.0.4844.51 (Official Build) (x86_64)
What OS (including version) are you using?
Mac 12.2.1
Test stream
No response
Configuration
{
"enableWorker": false
}
Additional player setup steps
No response
Checklist
- [X] The issue observed is not already reported by searching on Github under https://github.com/video-dev/hls.js/issues
- [X] The issue occurs in the stable client (latest release) on https://hls-js.netlify.com/demo and not just on my page
- [X] The issue occurs in the latest client (main branch) on https://hls-js-dev.netlify.com/demo and not just on my page
- [X] The stream has correct Access-Control-Allow-Origin headers (CORS)
- [X] There are no network errors such as 404s in the browser console when trying to play the stream
Steps to reproduce
- Use an HLS stream that has no audio tracks
Expected behaviour
The video should play without throwing an error.
What actually happened?
An error is thrown. If you catch the error and ignore it, video plays.
Console output
[log] >
hls.js?9414:16705 [log] > attachMedia
hls.js?9414:24873 [log] >
hls.js?9414:16705 [log] > attachMedia
hls.js?9414:4175 [log] > [buffer-controller]: Media source opened
hls.js?9414:4099 [log] > [subtitle-stream-controller]: STOPPED->IDLE
hls.js?9414:16771 [log] > stopLoad
hls.js?9414:4099 [log] > [subtitle-stream-controller]: IDLE->STOPPED
hls.js?9414:16734 [log] > loadSource:https://[URL-HERE]
hls.js?9414:9187 [log] > [stream-controller]: Trigger BUFFER_RESET
hls.js?9414:7745 [log] > [level-controller]: manifest loaded, 4 level(s) found, first bitrate: 401971
hls.js?9414:4272 [log] > 1 bufferCodec event(s) expected
hls.js?9414:16760 [log] > startLoad(-1)
hls.js?9414:8103 [log] > [level-controller]: switching to level 2 from -1
hls.js?9414:2482 [log] > [audio-track-controller]: Updating audio tracks, 0 track(s) found in "Audio Selector Group 1" group-id
hls.js?9414:2540 Assertion failed: Initial audio track should be selected when tracks are known
selectInitialTrack @ hls.js?9414:2540
switchLevel @ hls.js?9414:2484
onLevelSwitching @ hls.js?9414:2454
emit @ hls.js?9414:310
emit @ hls.js?9414:16650
trigger @ hls.js?9414:16655
set @ hls.js?9414:8115
set @ hls.js?9414:8179
set @ hls.js?9414:16904
startLoad @ hls.js?9414:8799
eval @ hls.js?9414:16762
startLoad @ hls.js?9414:16761
onManifestLoaded @ hls.js?9414:7768
emit @ hls.js?9414:310
emit @ hls.js?9414:16650
trigger @ hls.js?9414:16655
handleMasterPlaylist @ hls.js?9414:19526
loadsuccess @ hls.js?9414:19450
readystatechange @ hls.js?9414:27048
XMLHttpRequest.send (async)
(anonymous) @ VM77817:1
nrWrapper @ [CLASS_NAME]
XMLHttpRequest.send @ tti-polyfill.js?10b8:3
loadInternal @ hls.js?9414:26982
load @ hls.js?9414:26931
load @ hls.js?9414:19423
onManifestLoading @ hls.js?9414:19276
emit @ hls.js?9414:310
emit @ hls.js?9414:16650
trigger @ hls.js?9414:16655
loadSource @ hls.js?9414:16742
eval @ useVideoPlayer.tsx?0815:40
emit @ hls.js?9414:310
emit @ hls.js?9414:16650
trigger @ hls.js?9414:16655
BufferController._onMediaSourceOpen @ hls.js?9414:4180
nrWrapper @ [CLASS NAME]
react_devtools_backend.js:3973 [warn] > [audio-track-controller]: No track found for running audio group-ID: Audio Selector Group 1
overrideMethod @ react_devtools_backend.js:3973
selectInitialTrack @ hls.js?9414:2547
switchLevel @ hls.js?9414:2484
onLevelSwitching @ hls.js?9414:2454
emit @ hls.js?9414:310
emit @ hls.js?9414:16650
trigger @ hls.js?9414:16655
set @ hls.js?9414:8115
set @ hls.js?9414:8179
set @ hls.js?9414:16904
startLoad @ hls.js?9414:8799
eval @ hls.js?9414:16762
startLoad @ hls.js?9414:16761
onManifestLoaded @ hls.js?9414:7768
emit @ hls.js?9414:310
emit @ hls.js?9414:16650
trigger @ hls.js?9414:16655
handleMasterPlaylist @ hls.js?9414:19526
loadsuccess @ hls.js?9414:19450
readystatechange @ hls.js?9414:27048
XMLHttpRequest.send (async)
(anonymous) @ VM77817:1
nrWrapper @ [CLASS-NAME]
XMLHttpRequest.send @ tti-polyfill.js?10b8:3
loadInternal @ hls.js?9414:26982
load @ hls.js?9414:26931
load @ hls.js?9414:19423
onManifestLoading @ hls.js?9414:19276
emit @ hls.js?9414:310
emit @ hls.js?9414:16650
trigger @ hls.js?9414:16655
loadSource @ hls.js?9414:16742
eval @ useVideoPlayer.tsx?0815:40
emit @ hls.js?9414:310
emit @ hls.js?9414:16650
trigger @ hls.js?9414:16655
BufferController._onMediaSourceOpen @ hls.js?9414:4180
nrWrapper @ [CLASS NAME]
hls.js?9414:7995 [log] > [level-controller]: Attempt loading level index 2 with URL-id 0 https://[URL-HERE]
hls.js?9414:4099 [log] > [stream-controller]: STOPPED->IDLE
hls.js?9414:4099 [log] > [audio-stream-controller]: STOPPED->WAITING_TRACK
hls.js?9414:4099 [log] > [subtitle-stream-controller]: STOPPED->IDLE
hls.js?9414:9250 [log] > [stream-controller]: Level 2 loaded [1,3], cc [0, 0] duration:12
hls.js?9414:4763 [log] > [buffer-controller]: Updating Media Source duration to 12.000
hls.js?9414:3393 [log] > [stream-controller]: Loading fragment initSegment cc: 0 level: 2, target: 0
hls.js?9414:4099 [log] > [stream-controller]: IDLE->FRAG_LOADING
hls.js?9414:4099 [log] > [stream-controller]: FRAG_LOADING->IDLE
hls.js?9414:3324 [log] > [stream-controller]: Buffered main sn: initSegment of level 2
hls.js?9414:3393 [log] > [stream-controller]: Loading fragment 1 cc: 0 of [1-3] level: 2, target: 0
hls.js?9414:4099 [log] > [stream-controller]: IDLE->FRAG_LOADING
hls.js?9414:14222 [log] > [transmuxer-interface, main]: Starting new transmux session for sn: 1 p: -1 level: 2 id: 1
discontinuity: true
trackSwitch: true
contiguous: false
accurateTimeOffset: true
timeOffset: 0
hls.js?9414:4099 [log] > [stream-controller]: FRAG_LOADING->PARSING
hls.js?9414:9838 [log] > [stream-controller]: Init video buffer, container:video/mp4, codecs[level/parsed]=[avc1.4d401f/avc1.4d401f]
hls.js?9414:4834 [log] > [buffer-controller]: creating sourceBuffer(video/mp4;codecs=avc1.4d401f)
hls.js?9414:1643 [log] > [audio-stream-controller]: InitPTS for cc: 0 found from main: 0
hls.js?9414:3204 [log] > [stream-controller]: Loaded fragment 1 of level 2
hls.js?9414:14751 [log] > [transmuxer.ts]: Flushed fragment 1 of level 2
hls.js?9414:4099 [log] > [stream-controller]: PARSING->PARSED
hls.js?9414:3324 [log] > [stream-controller]: Buffered main sn: 1 of level 2 [0.067,4.071]
hls.js?9414:4099 [log] > [stream-controller]: PARSED->IDLE
hls.js?9414:8103 [log] > [level-controller]: switching to level 3 from 2
hls.js?9414:7995 [log] > [level-controller]: Attempt loading level index 3 with URL-id 0 https://[URL-HERE]
hls.js?9414:4099 [log] > [stream-controller]: IDLE->WAITING_LEVEL
hls.js?9414:9250 [log] > [stream-controller]: Level 3 loaded [1,3], cc [0, 0] duration:12
hls.js?9414:4099 [log] > [stream-controller]: WAITING_LEVEL->IDLE
hls.js?9414:3393 [log] > [stream-controller]: Loading fragment initSegment cc: 0 level: 3, target: 0
hls.js?9414:4099 [log] > [stream-controller]: IDLE->FRAG_LOADING
react_devtools_backend.js:3973 [warn] > skipping hole, adjusting currentTime from 0 to 0.116733
overrideMethod @ react_devtools_backend.js:3973
_trySkipBufferHole @ hls.js?9414:7070
poll @ hls.js?9414:6959
checkBuffer @ hls.js?9414:9538
onTickEnd @ hls.js?9414:8876
doTick @ hls.js?9414:8870
tick @ hls.js?9414:21673
setInterval (async)
nrWrapper @ [CLASS NAME]
setInterval @ hls.js?9414:21628
startLoad @ hls.js?9414:8779
eval @ hls.js?9414:16762
startLoad @ hls.js?9414:16761
onManifestLoaded @ hls.js?9414:7768
emit @ hls.js?9414:310
emit @ hls.js?9414:16650
trigger @ hls.js?9414:16655
handleMasterPlaylist @ hls.js?9414:19526
loadsuccess @ hls.js?9414:19450
readystatechange @ hls.js?9414:27048
XMLHttpRequest.send (async)
(anonymous) @ VM77817:1
nrWrapper @ [CLASS NAME]
XMLHttpRequest.send @ tti-polyfill.js?10b8:3
loadInternal @ hls.js?9414:26982
load @ hls.js?9414:26931
load @ hls.js?9414:19423
onManifestLoading @ hls.js?9414:19276
emit @ hls.js?9414:310
emit @ hls.js?9414:16650
trigger @ hls.js?9414:16655
loadSource @ hls.js?9414:16742
eval @ useVideoPlayer.tsx?0815:40
emit @ hls.js?9414:310
emit @ hls.js?9414:16650
trigger @ hls.js?9414:16655
BufferController._onMediaSourceOpen @ hls.js?9414:4180
nrWrapper @ [CLASS NAME]
hls.js?9414:3079 [log] > [stream-controller]: media seeking to 0.117, state: FRAG_LOADING
hls.js?9414:3079 [log] > [audio-stream-controller]: media seeking to 0.117, state: WAITING_TRACK
hls.js?9414:3079 [log] > [subtitle-stream-controller]: media seeking to 0.117, state: IDLE
hls.js?9414:4099 [log] > [stream-controller]: FRAG_LOADING->IDLE
hls.js?9414:3324 [log] > [stream-controller]: Buffered main sn: initSegment of level 3 [0.067,4.071]
hls.js?9414:3393 [log] > [stream-controller]: Loading fragment 2 cc: 0 of [1-3] level: 3, target: 4.071
hls.js?9414:4099 [log] > [stream-controller]: IDLE->FRAG_LOADING
hls.js?9414:9178 [log] > [stream-controller]: Media seeked to 0.119
hls.js?9414:14222 [log] > [transmuxer-interface, main]: Starting new transmux session for sn: 2 p: -1 level: 3 id: 1
discontinuity: false
trackSwitch: true
contiguous: false
accurateTimeOffset: true
timeOffset: 4
hls.js?9414:4099 [log] > [stream-controller]: FRAG_LOADING->PARSING
hls.js?9414:9838 [log] > [stream-controller]: Init video buffer, container:video/mp4, codecs[level/parsed]=[avc1.640028/avc1.640028]
hls.js?9414:3204 [log] > [stream-controller]: Loaded fragment 2 of level 3
hls.js?9414:14751 [log] > [transmuxer.ts]: Flushed fragment 2 of level 3
hls.js?9414:4099 [log] > [stream-controller]: PARSING->PARSED
hls.js?9414:3324 [log] > [stream-controller]: Buffered main sn: 2 of level 3 [0.067,8.075]
hls.js?9414:4099 [log] > [stream-controller]: PARSED->IDLE
hls.js?9414:3393 [log] > [stream-controller]: Loading fragment 3 cc: 0 of [1-3] level: 3, target: 8.075
hls.js?9414:4099 [log] > [stream-controller]: IDLE->FRAG_LOADING
hls.js?9414:4099 [log] > [stream-controller]: FRAG_LOADING->PARSING
hls.js?9414:3204 [log] > [stream-controller]: Loaded fragment 3 of level 3
hls.js?9414:14751 [log] > [transmuxer.ts]: Flushed fragment 3 of level 3
hls.js?9414:4099 [log] > [stream-controller]: PARSING->PARSED
hls.js?9414:3324 [log] > [stream-controller]: Buffered main sn: 3 of level 3 [0.067,11.078]
hls.js?9414:4099 [log] > [stream-controller]: PARSED->IDLE
hls.js?9414:4643 [log] > [buffer-controller]: video sourceBuffer now EOS
hls.js?9414:4099 [log] > [stream-controller]: IDLE->ENDED
hls.js?9414:4198 [log] > [buffer-controller]: Media source ended
Chrome media internals output
No response
I tested the stream without the audio track, it works fine. Probably a stream issue.
@mtoczko We currently have the same problem. Would you mind sharing if you also use Cloudflare Stream as a HLS source?
Assertion failed: Initial audio track should be selected when tracks are known
Hi @Conceptiks Can you share a sample stream?
In the manifest file it should be
CODECS="avc1.64002a" only video
CODECS="avc1.640020,mp4a.40.2" video + audio
I can provide a sample stream: https://videodelivery.net/3229bc21f72e173f8cf3ae88afe8234c/manifest/video.m3u8 We've run into the same problem. We're also using Cloudflare too.
I can repro on the demo page as well. It doesn't happen 100% of the time, but if you retry enough (like, re-clicking the "Apply" button) it will happen eventually. Demo link
The error ⬇️

Calling this.setAudioTrack(null) when there is no audio tracks fixes a problem.
selectInitialTrack() {
var audioTracks = this.tracksInGroup;
if (!audioTracks.length) {
this.setAudioTrack(null)
return;
}
var trackId = this.findTrackId(this.currentTrack) | this.findTrackId(null);
if (trackId !== -1) {
this.setAudioTrack(trackId);
} else {
var error = new Error("No track found for running audio group-ID: " + this.groupId + " track count: " + audioTracks.length);
this.warn(error.message);
this.hls.trigger(Events.ERROR, {
type: ErrorTypes.MEDIA_ERROR,
details: ErrorDetails.AUDIO_TRACK_LOAD_ERROR,
fatal: true,
error: error
});
}
}
There is a fix in dev with #5562 and will be included in v1.5.0:
https://github.com/video-dev/hls.js/blob/d0d52044f005a9a3186582ca91aece507b8a45ca/src/controller/audio-track-controller.ts#L216-L218
If you'd like this change in a standalone patch, please submit a PR. Note that null is not valid input for setAudioTrack.
It does not handle the case where there are no tracks. For verification and a fix, please provide a sample HLS asset that can be used to reproduce the issue. The asset in https://github.com/video-dev/hls.js/issues/4602#issuecomment-1232020921 has no audio-groups for any of the variants so it is impossible for selectInitialTrack() to be called.
Let me know if #5822 resolves the issue. @lp-contentplus, I took a cue from your solution and return early from selectInitialTrack when in an empty audio-group. The track id is and current track are reset to -1 and null respectfully before the tracks update event is triggered.
The assertion errors in the initial issue description matching the thread up to Aug 22 were removed in v1.4 at while point this issue should have been closed.
#5822 Addresses the escape mentioned last week https://github.com/video-dev/hls.js/issues/4602#issuecomment-1717686269 but without having concrete steps to reproduce.
If this issue is still reproducible in dev / v1.5.0 or newer (https://hlsjs-dev.video-dev.org/demo/) please file a new issue with steps to reproduce and the version/demo link used to reproduce it.