feat: add a default audio codec for the HLS video player (#37525)#19
Conversation
This seems to reduce instances of audio garbling when switching levels during HLS video streaming.
There was a problem hiding this comment.
Pull Request Overview
This PR adds a default audio codec configuration for the HLS video player to help reduce audio issues when HLS videos perform bitrate level switches during playback. According to the PR description, this addresses garbled audio problems that occur when videos switch from the default starting bitrate to a different bitrate, particularly for content from external sources.
Key changes:
- Sets a default audio codec value (
mp4a.40.5) in the HLS video player configuration if one is not already provided
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| if (!this.config.defaultAudioCodec) { | ||
| this.config.defaultAudioCodec = "mp4a.40.5"; | ||
| } |
There was a problem hiding this comment.
The defaultAudioCodec configuration is set on this.config but is never passed to the HLS constructor. Lines 54 and 56 instantiate HLS with only {autoStartLoad: true/false}. To fix this, include defaultAudioCodec in the HLS configuration object: this.hls = new HLS({autoStartLoad: true, defaultAudioCodec: this.config.defaultAudioCodec});
Deploy of openedx#37525
Description
Some HLS video sources, when performing a level switch from default starting bitrate to a different bitrate encounter an error which causes garbled audio.
Defining a default audio codec seems to reduce this occurrence. See the docs which note that omitting a default value can cause issues.
NOTE that the real fix is probably to update our now five years out-of-date HLS library version but that is a whole other conversation for a different day and can probably just be deferred to extraction of the video block.
Testing instructions