From 1342bedad0061366d63a3bd63d67757721c2431e Mon Sep 17 00:00:00 2001 From: Dmitry Lyzo Date: Sun, 5 May 2024 21:09:52 +0300 Subject: [PATCH 1/2] Limit maximum FLAC channels to 2 on webOS --- src/scripts/browserDeviceProfile.js | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/scripts/browserDeviceProfile.js b/src/scripts/browserDeviceProfile.js index 542b535f88..6c1550ef25 100644 --- a/src/scripts/browserDeviceProfile.js +++ b/src/scripts/browserDeviceProfile.js @@ -883,6 +883,24 @@ export default function (options) { }); } + if (browser.web0s) { + const flacConditions = [ + // webOS doesn't seem to support FLAC with more than 2 channels + { + Condition: 'LessThanEqual', + Property: 'AudioChannels', + Value: '2', + IsRequired: false + } + ]; + + profile.CodecProfiles.push({ + Type: 'VideoAudio', + Codec: 'flac', + Conditions: flacConditions + }); + } + let maxH264Level = 42; let h264Profiles = 'high|main|baseline|constrained baseline'; From fb87dfbf5ec473b029738342363fe016177499a6 Mon Sep 17 00:00:00 2001 From: Dmitry Lyzo Date: Wed, 15 May 2024 02:56:37 +0300 Subject: [PATCH 2/2] Add specialized video transcoding profile with FLAC for webOS webOS doesn't seem to support FLAC with more than 2 channels. Split each video transcoding profile with FLAC so that the containing FLAC is only applied to 2 channels audio. --- src/scripts/browserDeviceProfile.js | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/src/scripts/browserDeviceProfile.js b/src/scripts/browserDeviceProfile.js index 6c1550ef25..737d93f4b0 100644 --- a/src/scripts/browserDeviceProfile.js +++ b/src/scripts/browserDeviceProfile.js @@ -899,6 +899,30 @@ export default function (options) { Codec: 'flac', Conditions: flacConditions }); + + const flacTranscodingProfiles = []; + + // Split each video transcoding profile with FLAC so that the containing FLAC is only applied to 2 channels audio + profile.TranscodingProfiles.forEach(transcodingProfile => { + if (transcodingProfile.Type !== 'Video') return; + + const audioCodecs = transcodingProfile.AudioCodec.split(','); + + if (!audioCodecs.includes('flac')) return; + + const flacTranscodingProfile = { ...transcodingProfile }; + flacTranscodingProfile.AudioCodec = 'flac'; + flacTranscodingProfile.ApplyConditions = [ + ...flacTranscodingProfile.ApplyConditions || [], + ...flacConditions + ]; + + flacTranscodingProfiles.push(flacTranscodingProfile); + + transcodingProfile.AudioCodec = audioCodecs.filter(codec => codec != 'flac').join(','); + }); + + profile.TranscodingProfiles.push(...flacTranscodingProfiles); } let maxH264Level = 42;