hls.js
hls.js copied to clipboard
Using Audio Only levels along with Video levels
What do you want to do with Hls.js?
Hello, We are trying to have a stream that has both audio levels as well as video levels. When manifest is loaded, I can see the audio level but it looks like the audio levels are filtered here
I'm curious on why this is filtered out of the levels. Also if you can guide me on how to still get it and set as currentLevel that'd be great.
thank you :)
What have you tried so far?
currently we just do
hlsjs.currentLevel = hlsjs.levels[userSelectedLevel]
but since the audio levels are removed from the levels array, we are unable to select the audio level.
HLS.js filters out audio-only levels from AV streams for a couple of reasons:
On the technical side, HLS.js cannot seamlessly transition between playback of audio-video and audio-only using MSE in a straightforward way. For example, suppose we set up the player with audio and video or muxed AV SourceBuffers and, at some point, after appending video and audio, only append audio. In that case, playback will stall when it reaches a lack of video.
From a viewer's perspective, a user might think the video froze when playback transitions from audio-video to audio-only before their eyes if they were unaware that there was an audio-only mode. For example, this can happen in Safari when playing a stream authored with an audio-only variant, even though it was intended only to be played while visible on screen.
If you want to play audio-only in the background, there is an open feature request in #3480.
hey thanks for the response. couple of questions here.
- is this something the MSE api do intentionally or a bug?
- is there a way to still tell hls.js not to remove the audio levels? I get that its not straightforward to play it but I was wondering if we could still get it in
hls.levels, maybe we can do some sort of hack for the time being.
Here's where the audio level(s) are filtered out when there are levels with video or resolution: https://github.com/video-dev/hls.js/blob/v1.2.3/src/controller/level-controller.ts#L133-L138