From 6e32ea052d4132645884e17d814922ce0ccd4576 Mon Sep 17 00:00:00 2001 From: dmitrylyzo <56478732+dmitrylyzo@users.noreply.github.com> Date: Sat, 25 May 2024 11:50:34 -0400 Subject: [PATCH] Backport pull request #5452 from jellyfin-web/release-10.9.z Limit maximum FLAC audio channels in video to 2 on webOS Original-merge: 9d9b69edd52872086628e853c67facc4f181b1fb Merged-by: thornbill Backported-by: Joshua M. Boniface --- src/scripts/browserDeviceProfile.js | 42 +++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/src/scripts/browserDeviceProfile.js b/src/scripts/browserDeviceProfile.js index 542b535f88..737d93f4b0 100644 --- a/src/scripts/browserDeviceProfile.js +++ b/src/scripts/browserDeviceProfile.js @@ -883,6 +883,48 @@ 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 + }); + + 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; let h264Profiles = 'high|main|baseline|constrained baseline';