From be3b321ffb2128fb777220a223243ef0daa092f2 Mon Sep 17 00:00:00 2001 From: gnattu Date: Mon, 8 Apr 2024 13:49:45 +0800 Subject: [PATCH 1/3] fix: use correct hls containers for audio The current container setting was set 4 years ago and does not reflect current browsers. We should prioritize using fmp4 when possible and fallback to mpegts if necessary. --- src/scripts/browserDeviceProfile.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/scripts/browserDeviceProfile.js b/src/scripts/browserDeviceProfile.js index 6733f3a3e9..6815d1d0f9 100644 --- a/src/scripts/browserDeviceProfile.js +++ b/src/scripts/browserDeviceProfile.js @@ -718,9 +718,13 @@ export default function (options) { const hlsBreakOnNonKeyFrames = browser.iOS || browser.osx || browser.edge || !canPlayNativeHls(); if (canPlayHls() && browser.enableHlsAudio !== false) { + let enableFmp4Hls = userSettings.preferFmp4HlsContainer(); + if ((browser.safari || browser.tizen || browser.web0s) && !canPlayNativeHlsInFmp4()) { + enableFmp4Hls = false; + } profile.TranscodingProfiles.push({ // hlsjs, edge, and android all seem to require ts container - Container: !canPlayNativeHls() || browser.edge || browser.android ? 'ts' : 'aac', + Container: enableFmp4Hls ? 'mp4' : 'ts', Type: 'Audio', AudioCodec: 'aac', Context: 'Streaming', From 4b054caebda553a35dabdc059fbbd76d647f8242 Mon Sep 17 00:00:00 2001 From: gnattu Date: Mon, 8 Apr 2024 14:03:02 +0800 Subject: [PATCH 2/3] chore: remove leftover comment --- src/scripts/browserDeviceProfile.js | 1 - 1 file changed, 1 deletion(-) diff --git a/src/scripts/browserDeviceProfile.js b/src/scripts/browserDeviceProfile.js index 6815d1d0f9..932cd9050c 100644 --- a/src/scripts/browserDeviceProfile.js +++ b/src/scripts/browserDeviceProfile.js @@ -723,7 +723,6 @@ export default function (options) { enableFmp4Hls = false; } profile.TranscodingProfiles.push({ - // hlsjs, edge, and android all seem to require ts container Container: enableFmp4Hls ? 'mp4' : 'ts', Type: 'Audio', AudioCodec: 'aac', From f8b5c36fef655a6cdcd525c07ba21b5693086e1e Mon Sep 17 00:00:00 2001 From: gnattu Date: Tue, 9 Apr 2024 10:40:17 +0800 Subject: [PATCH 3/3] chore: reuse enableFmp4Hls for video and audio --- src/scripts/browserDeviceProfile.js | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/src/scripts/browserDeviceProfile.js b/src/scripts/browserDeviceProfile.js index 932cd9050c..33e07e4f0c 100644 --- a/src/scripts/browserDeviceProfile.js +++ b/src/scripts/browserDeviceProfile.js @@ -716,12 +716,12 @@ export default function (options) { profile.TranscodingProfiles = []; const hlsBreakOnNonKeyFrames = browser.iOS || browser.osx || browser.edge || !canPlayNativeHls(); + let enableFmp4Hls = userSettings.preferFmp4HlsContainer(); + if ((browser.safari || browser.tizen || browser.web0s) && !canPlayNativeHlsInFmp4()) { + enableFmp4Hls = false; + } if (canPlayHls() && browser.enableHlsAudio !== false) { - let enableFmp4Hls = userSettings.preferFmp4HlsContainer(); - if ((browser.safari || browser.tizen || browser.web0s) && !canPlayNativeHlsInFmp4()) { - enableFmp4Hls = false; - } profile.TranscodingProfiles.push({ Container: enableFmp4Hls ? 'mp4' : 'ts', Type: 'Audio', @@ -760,10 +760,6 @@ export default function (options) { }); if (canPlayHls() && options.enableHls !== false) { - let enableFmp4Hls = userSettings.preferFmp4HlsContainer(); - if ((browser.safari || browser.tizen || browser.web0s) && !canPlayNativeHlsInFmp4()) { - enableFmp4Hls = false; - } if (hlsInFmp4VideoCodecs.length && hlsInFmp4VideoAudioCodecs.length && enableFmp4Hls) { // HACK: Since there is no filter for TS/MP4 in the API, specify HLS support in general and rely on retry after DirectPlay error // FIXME: Need support for {Container: 'mp4', Protocol: 'hls'} or {Container: 'hls', SubContainer: 'mp4'}