aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuke Pulverenti <luke.pulverenti@gmail.com>2015-05-15 12:02:26 -0400
committerLuke Pulverenti <luke.pulverenti@gmail.com>2015-05-15 12:02:26 -0400
commit41a63028f1e3ecd54c676135ce01934be368691a (patch)
tree1171a1cb47b6cc5b3039587427748fd18dd85afb
parentd2949d6e0375f4bc65566b96f3f832249ae5cedd (diff)
fixes #101 - FFMpeg iTunes m4a transcode issue
-rw-r--r--MediaBrowser.Api/Playback/BaseStreamingService.cs27
1 files changed, 16 insertions, 11 deletions
diff --git a/MediaBrowser.Api/Playback/BaseStreamingService.cs b/MediaBrowser.Api/Playback/BaseStreamingService.cs
index 5e06ab1d0..d3241a443 100644
--- a/MediaBrowser.Api/Playback/BaseStreamingService.cs
+++ b/MediaBrowser.Api/Playback/BaseStreamingService.cs
@@ -769,26 +769,31 @@ namespace MediaBrowser.Api.Playback
/// <returns>System.Nullable{System.Int32}.</returns>
private int? GetNumAudioChannelsParam(StreamRequest request, MediaStream audioStream, string outputAudioCodec)
{
- if (audioStream != null)
- {
- var codec = outputAudioCodec ?? string.Empty;
+ var inputChannels = audioStream == null
+ ? null
+ : audioStream.Channels;
- if (audioStream.Channels > 2 && codec.IndexOf("wma", StringComparison.OrdinalIgnoreCase) != -1)
- {
- // wmav2 currently only supports two channel output
- return 2;
- }
+ 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);
}
if (request.MaxAudioChannels.HasValue)
{
- if (audioStream != null && audioStream.Channels.HasValue)
+ if (inputChannels.HasValue)
{
- return Math.Min(request.MaxAudioChannels.Value, audioStream.Channels.Value);
+ return Math.Min(request.MaxAudioChannels.Value, inputChannels.Value);
}
+ var channelLimit = codec.IndexOf("mp3", StringComparison.OrdinalIgnoreCase) != -1
+ ? 2
+ : 5;
+
// 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, 5);
+ return Math.Min(request.MaxAudioChannels.Value, channelLimit);
}
return request.AudioChannels;