aboutsummaryrefslogtreecommitdiff
path: root/MediaBrowser.Controller/MediaEncoding/EncodingHelper.cs
diff options
context:
space:
mode:
authorgnattu <gnattu@users.noreply.github.com>2024-04-23 00:23:36 +0800
committerGitHub <noreply@github.com>2024-04-22 10:23:36 -0600
commit374b6ca0e22719df25b8d0aa51c510515b928104 (patch)
tree586c2d8276b15a2d22115f4f0abd52df355df421 /MediaBrowser.Controller/MediaEncoding/EncodingHelper.cs
parent09b02296700e8a2affa17555062516206e543f7c (diff)
Only apply custom downmix to 5.1 audios (#11401)
Diffstat (limited to 'MediaBrowser.Controller/MediaEncoding/EncodingHelper.cs')
-rw-r--r--MediaBrowser.Controller/MediaEncoding/EncodingHelper.cs19
1 files changed, 16 insertions, 3 deletions
diff --git a/MediaBrowser.Controller/MediaEncoding/EncodingHelper.cs b/MediaBrowser.Controller/MediaEncoding/EncodingHelper.cs
index eb375c8a2..9c087f011 100644
--- a/MediaBrowser.Controller/MediaEncoding/EncodingHelper.cs
+++ b/MediaBrowser.Controller/MediaEncoding/EncodingHelper.cs
@@ -2627,7 +2627,7 @@ namespace MediaBrowser.Controller.MediaEncoding
&& channels.Value == 2
&& state.AudioStream is not null
&& state.AudioStream.Channels.HasValue
- && state.AudioStream.Channels.Value > 5)
+ && state.AudioStream.Channels.Value == 6)
{
switch (encodingOptions.DownMixStereoAlgorithm)
{
@@ -2720,7 +2720,20 @@ namespace MediaBrowser.Controller.MediaEncoding
if (state.TranscodingType != TranscodingJobType.Progressive
&& ((resultChannels > 2 && resultChannels < 6) || resultChannels == 7))
{
- resultChannels = 2;
+ // We can let FFMpeg supply an extra LFE channel for 5ch and 7ch to make them 5.1 and 7.1
+ if (resultChannels == 5)
+ {
+ resultChannels = 6;
+ }
+ else if (resultChannels == 7)
+ {
+ resultChannels = 8;
+ }
+ else
+ {
+ // For other weird layout, just downmix to stereo for compatibility
+ resultChannels = 2;
+ }
}
}
@@ -6903,7 +6916,7 @@ namespace MediaBrowser.Controller.MediaEncoding
var channels = state.OutputAudioChannels;
- if (channels.HasValue && ((channels.Value != 2 && state.AudioStream.Channels <= 5) || encodingOptions.DownMixStereoAlgorithm == DownMixStereoAlgorithms.None))
+ if (channels.HasValue && ((channels.Value != 2 && state.AudioStream?.Channels != 6) || encodingOptions.DownMixStereoAlgorithm == DownMixStereoAlgorithms.None))
{
args += " -ac " + channels.Value;
}