aboutsummaryrefslogtreecommitdiff
path: root/MediaBrowser.MediaEncoding/Encoder/EncodingJobFactory.cs
diff options
context:
space:
mode:
authorLuke <luke.pulverenti@gmail.com>2016-12-28 16:13:12 -0500
committerGitHub <noreply@github.com>2016-12-28 16:13:12 -0500
commit2cb0f3eed635bb468b3672d08dca9a720b4fb48f (patch)
tree1a0d7c53ec148619ae966a81187413a33ca9a8a4 /MediaBrowser.MediaEncoding/Encoder/EncodingJobFactory.cs
parente47ccdce4247b93faa6d27849b255aac83324c42 (diff)
parentc10b152018967ddafe72efbccfe8ca6c586cbf04 (diff)
Merge pull request #2372 from MediaBrowser/beta
Beta
Diffstat (limited to 'MediaBrowser.MediaEncoding/Encoder/EncodingJobFactory.cs')
-rw-r--r--MediaBrowser.MediaEncoding/Encoder/EncodingJobFactory.cs44
1 files changed, 32 insertions, 12 deletions
diff --git a/MediaBrowser.MediaEncoding/Encoder/EncodingJobFactory.cs b/MediaBrowser.MediaEncoding/Encoder/EncodingJobFactory.cs
index e197bdb6f..d6340d4ab 100644
--- a/MediaBrowser.MediaEncoding/Encoder/EncodingJobFactory.cs
+++ b/MediaBrowser.MediaEncoding/Encoder/EncodingJobFactory.cs
@@ -370,30 +370,50 @@ namespace MediaBrowser.MediaEncoding.Encoder
inputChannels = null;
}
+ int? transcoderChannelLimit = null;
var codec = outputAudioCodec ?? string.Empty;
if (codec.IndexOf("wma", StringComparison.OrdinalIgnoreCase) != -1)
{
// wmav2 currently only supports two channel output
- return Math.Min(2, inputChannels ?? 2);
+ transcoderChannelLimit = 2;
}
- if (request.MaxAudioChannels.HasValue)
+ else if (codec.IndexOf("mp3", StringComparison.OrdinalIgnoreCase) != -1)
{
- var channelLimit = codec.IndexOf("mp3", StringComparison.OrdinalIgnoreCase) != -1
- ? 2
- : 6;
+ // libmp3lame currently only supports two channel output
+ transcoderChannelLimit = 2;
+ }
+ else
+ {
+ // If we don't have any media info then limit it to 6 to prevent encoding errors due to asking for too many channels
+ transcoderChannelLimit = 6;
+ }
- if (inputChannels.HasValue)
- {
- channelLimit = Math.Min(channelLimit, inputChannels.Value);
- }
+ var isTranscodingAudio = !string.Equals(codec, "copy", StringComparison.OrdinalIgnoreCase);
- // If we don't have any media info then limit it to 5 to prevent encoding errors due to asking for too many channels
- return Math.Min(request.MaxAudioChannels.Value, channelLimit);
+ int? resultChannels = null;
+ if (isTranscodingAudio)
+ {
+ resultChannels = request.TranscodingMaxAudioChannels;
+ }
+ resultChannels = resultChannels ?? request.MaxAudioChannels ?? request.AudioChannels;
+
+ if (inputChannels.HasValue)
+ {
+ resultChannels = resultChannels.HasValue
+ ? Math.Min(resultChannels.Value, inputChannels.Value)
+ : inputChannels.Value;
+ }
+
+ if (isTranscodingAudio && transcoderChannelLimit.HasValue)
+ {
+ resultChannels = resultChannels.HasValue
+ ? Math.Min(resultChannels.Value, transcoderChannelLimit.Value)
+ : transcoderChannelLimit.Value;
}
- return request.AudioChannels;
+ return resultChannels ?? request.AudioChannels;
}
private int? GetVideoBitrateParamValue(EncodingJobOptions request, MediaStream videoStream, string outputVideoCodec)