From 6e0ad2ed1b36d7c867e1ca243675eb8311b98f61 Mon Sep 17 00:00:00 2001 From: gnattu Date: Sun, 18 Aug 2024 07:20:08 +0800 Subject: [PATCH] Override mp3 remux container (#5914) * Override mp3 remux container The server generally filters out invalid containers for HLS in most cases. However, MP3 is a special case because, while it is technically possible and allowed as a codec for fMP4 on the server side, most browsers do not support it. Override the remux container to force MPEG-TS for MP3. The server will still direct play MP3 in an MP3 container. This is useful for supporting universal containers like MKA. * Fix lint Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --------- Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --- src/scripts/browserDeviceProfile.js | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/scripts/browserDeviceProfile.js b/src/scripts/browserDeviceProfile.js index d4b692dd6a..85089e6d0e 100644 --- a/src/scripts/browserDeviceProfile.js +++ b/src/scripts/browserDeviceProfile.js @@ -715,6 +715,17 @@ export default function (options) { }); ['opus', 'mp3', 'mp2', 'aac', 'flac', 'alac', 'webma', 'wma', 'wav', 'ogg', 'oga'].filter(canPlayAudioFormat).forEach(function (audioFormat) { + // Place container overrides before direct profile for remux container override + if (audioFormat == 'mp3' && !canPlayMp3VideoAudioInHls) { + // mp3 is a special case because it is allowed in hls-fmp4 on the server-side + // but not really supported in most browsers + profile.DirectPlayProfiles.push({ + Container: 'ts', + AudioCodec: 'mp3', + Type: 'Audio' + }); + } + profile.DirectPlayProfiles.push({ Container: audioFormat, Type: 'Audio'