mirror of
https://github.com/jellyfin/jellyfin.git
synced 2025-04-24 22:17:25 -04:00
Only apply custom downmix to 5.1 audios (#11401)
This commit is contained in:
parent
09b0229670
commit
374b6ca0e2
3 changed files with 22 additions and 11 deletions
|
@ -1712,12 +1712,11 @@ public class DynamicHlsController : BaseJellyfinApiController
|
||||||
|
|
||||||
var channels = state.OutputAudioChannels;
|
var channels = state.OutputAudioChannels;
|
||||||
|
|
||||||
|
var useDownMixAlgorithm = state.AudioStream.Channels is 6 && _encodingOptions.DownMixStereoAlgorithm != DownMixStereoAlgorithms.None;
|
||||||
|
|
||||||
if (channels.HasValue
|
if (channels.HasValue
|
||||||
&& (channels.Value != 2
|
&& (channels.Value != 2
|
||||||
|| (state.AudioStream is not null
|
|| (state.AudioStream?.Channels != null && !useDownMixAlgorithm)))
|
||||||
&& state.AudioStream.Channels.HasValue
|
|
||||||
&& state.AudioStream.Channels.Value > 5
|
|
||||||
&& _encodingOptions.DownMixStereoAlgorithm == DownMixStereoAlgorithms.None)))
|
|
||||||
{
|
{
|
||||||
args += " -ac " + channels.Value;
|
args += " -ac " + channels.Value;
|
||||||
}
|
}
|
||||||
|
|
|
@ -166,6 +166,9 @@ public static class StreamingHelpers
|
||||||
}
|
}
|
||||||
|
|
||||||
var outputAudioCodec = streamingRequest.AudioCodec;
|
var outputAudioCodec = streamingRequest.AudioCodec;
|
||||||
|
state.OutputAudioCodec = outputAudioCodec;
|
||||||
|
state.OutputContainer = (containerInternal ?? string.Empty).TrimStart('.');
|
||||||
|
state.OutputAudioChannels = encodingHelper.GetNumAudioChannelsParam(state, state.AudioStream, state.OutputAudioCodec);
|
||||||
if (EncodingHelper.LosslessAudioCodecs.Contains(outputAudioCodec))
|
if (EncodingHelper.LosslessAudioCodecs.Contains(outputAudioCodec))
|
||||||
{
|
{
|
||||||
state.OutputAudioBitrate = state.AudioStream.BitRate ?? 0;
|
state.OutputAudioBitrate = state.AudioStream.BitRate ?? 0;
|
||||||
|
@ -180,10 +183,6 @@ public static class StreamingHelpers
|
||||||
containerInternal = ".pcm";
|
containerInternal = ".pcm";
|
||||||
}
|
}
|
||||||
|
|
||||||
state.OutputAudioCodec = outputAudioCodec;
|
|
||||||
state.OutputContainer = (containerInternal ?? string.Empty).TrimStart('.');
|
|
||||||
state.OutputAudioChannels = encodingHelper.GetNumAudioChannelsParam(state, state.AudioStream, state.OutputAudioCodec);
|
|
||||||
|
|
||||||
if (state.VideoRequest is not null)
|
if (state.VideoRequest is not null)
|
||||||
{
|
{
|
||||||
state.OutputVideoCodec = state.Request.VideoCodec;
|
state.OutputVideoCodec = state.Request.VideoCodec;
|
||||||
|
|
|
@ -2627,7 +2627,7 @@ namespace MediaBrowser.Controller.MediaEncoding
|
||||||
&& channels.Value == 2
|
&& channels.Value == 2
|
||||||
&& state.AudioStream is not null
|
&& state.AudioStream is not null
|
||||||
&& state.AudioStream.Channels.HasValue
|
&& state.AudioStream.Channels.HasValue
|
||||||
&& state.AudioStream.Channels.Value > 5)
|
&& state.AudioStream.Channels.Value == 6)
|
||||||
{
|
{
|
||||||
switch (encodingOptions.DownMixStereoAlgorithm)
|
switch (encodingOptions.DownMixStereoAlgorithm)
|
||||||
{
|
{
|
||||||
|
@ -2720,7 +2720,20 @@ namespace MediaBrowser.Controller.MediaEncoding
|
||||||
if (state.TranscodingType != TranscodingJobType.Progressive
|
if (state.TranscodingType != TranscodingJobType.Progressive
|
||||||
&& ((resultChannels > 2 && resultChannels < 6) || resultChannels == 7))
|
&& ((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;
|
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;
|
args += " -ac " + channels.Value;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue