From bc6ec08322a6d9111849dd4661bdda3746347835 Mon Sep 17 00:00:00 2001 From: nyanmisaka Date: Thu, 24 Dec 2020 19:41:02 +0800 Subject: [PATCH 1/3] avoid transcoding to 3ch audio for HLS streaming --- .../MediaEncoding/EncodingHelper.cs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/MediaBrowser.Controller/MediaEncoding/EncodingHelper.cs b/MediaBrowser.Controller/MediaEncoding/EncodingHelper.cs index 6667c1c3b..17201551a 100644 --- a/MediaBrowser.Controller/MediaEncoding/EncodingHelper.cs +++ b/MediaBrowser.Controller/MediaEncoding/EncodingHelper.cs @@ -1722,6 +1722,16 @@ namespace MediaBrowser.Controller.MediaEncoding : transcoderChannelLimit.Value; } + // Avoid transcoding to audio channels other than 1ch, 2ch, 6ch (5.1 layout) and 8ch (7.1 layout). + // https://developer.apple.com/documentation/http_live_streaming/hls_authoring_specification_for_apple_devices + if (isTranscodingAudio + && resultChannels.HasValue + && resultChannels.Value > 2 + && resultChannels.Value < 6) + { + resultChannels = 2; + } + return resultChannels; } From ae1187042af7bc9a144d184a31017b6bd32eefcd Mon Sep 17 00:00:00 2001 From: nyanmisaka Date: Thu, 24 Dec 2020 20:06:55 +0800 Subject: [PATCH 2/3] also avoid 7ch transcoding --- MediaBrowser.Controller/MediaEncoding/EncodingHelper.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/MediaBrowser.Controller/MediaEncoding/EncodingHelper.cs b/MediaBrowser.Controller/MediaEncoding/EncodingHelper.cs index 17201551a..29978a56c 100644 --- a/MediaBrowser.Controller/MediaEncoding/EncodingHelper.cs +++ b/MediaBrowser.Controller/MediaEncoding/EncodingHelper.cs @@ -1726,8 +1726,7 @@ namespace MediaBrowser.Controller.MediaEncoding // https://developer.apple.com/documentation/http_live_streaming/hls_authoring_specification_for_apple_devices if (isTranscodingAudio && resultChannels.HasValue - && resultChannels.Value > 2 - && resultChannels.Value < 6) + && (resultChannels.Value > 2 && resultChannels.Value < 6 || resultChannels.Value == 7)) { resultChannels = 2; } From 470f40442cd6ecbcfe81888804bf4e6a04846aec Mon Sep 17 00:00:00 2001 From: Nyanmisaka Date: Sat, 26 Dec 2020 02:28:38 +0800 Subject: [PATCH 3/3] not apply to progressive playback --- MediaBrowser.Controller/MediaEncoding/EncodingHelper.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/MediaBrowser.Controller/MediaEncoding/EncodingHelper.cs b/MediaBrowser.Controller/MediaEncoding/EncodingHelper.cs index 29978a56c..efab87a38 100644 --- a/MediaBrowser.Controller/MediaEncoding/EncodingHelper.cs +++ b/MediaBrowser.Controller/MediaEncoding/EncodingHelper.cs @@ -1725,6 +1725,7 @@ namespace MediaBrowser.Controller.MediaEncoding // Avoid transcoding to audio channels other than 1ch, 2ch, 6ch (5.1 layout) and 8ch (7.1 layout). // https://developer.apple.com/documentation/http_live_streaming/hls_authoring_specification_for_apple_devices if (isTranscodingAudio + && state.TranscodingType != TranscodingJobType.Progressive && resultChannels.HasValue && (resultChannels.Value > 2 && resultChannels.Value < 6 || resultChannels.Value == 7)) {