diff options
Diffstat (limited to 'MediaBrowser.MediaEncoding')
4 files changed, 59 insertions, 15 deletions
diff --git a/MediaBrowser.MediaEncoding/BdInfo/BdInfoExaminer.cs b/MediaBrowser.MediaEncoding/BdInfo/BdInfoExaminer.cs index bf7343f3d..219b1f3c5 100644 --- a/MediaBrowser.MediaEncoding/BdInfo/BdInfoExaminer.cs +++ b/MediaBrowser.MediaEncoding/BdInfo/BdInfoExaminer.cs @@ -30,6 +30,11 @@ namespace MediaBrowser.MediaEncoding.BdInfo /// <returns>BlurayDiscInfo.</returns> public BlurayDiscInfo GetDiscInfo(string path) { + if (string.IsNullOrWhiteSpace(path)) + { + throw new ArgumentNullException("path"); + } + var bdrom = new BDROM(path, _fileSystem, _textEncoding); bdrom.Scan(); diff --git a/MediaBrowser.MediaEncoding/Encoder/BaseEncoder.cs b/MediaBrowser.MediaEncoding/Encoder/BaseEncoder.cs index b8087fded..80bbc87e3 100644 --- a/MediaBrowser.MediaEncoding/Encoder/BaseEncoder.cs +++ b/MediaBrowser.MediaEncoding/Encoder/BaseEncoder.cs @@ -474,7 +474,19 @@ namespace MediaBrowser.MediaEncoding.Encoder arg += string.Format(" -canvas_size {0}:{1}", state.VideoStream.Width.Value.ToString(CultureInfo.InvariantCulture), Convert.ToInt32(height).ToString(CultureInfo.InvariantCulture)); } - arg += " -i \"" + state.SubtitleStream.Path + "\""; + + var subtitlePath = state.SubtitleStream.Path; + + if (string.Equals(Path.GetExtension(subtitlePath), ".sub", StringComparison.OrdinalIgnoreCase)) + { + var idxFile = Path.ChangeExtension(subtitlePath, ".idx"); + if (FileSystem.FileExists(idxFile)) + { + subtitlePath = idxFile; + } + } + + arg += " -i \"" + subtitlePath + "\""; } } @@ -816,7 +828,7 @@ namespace MediaBrowser.MediaEncoding.Encoder } // h264 - return string.Format(" -b:v {0} -maxrate {0} -bufsize {1}", + return string.Format(" -maxrate {0} -bufsize {1}", bitrate.Value.ToString(UsCulture), (bitrate.Value * 2).ToString(UsCulture)); } 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) diff --git a/MediaBrowser.MediaEncoding/Encoder/MediaEncoder.cs b/MediaBrowser.MediaEncoding/Encoder/MediaEncoder.cs index 23e63dad0..89730a11f 100644 --- a/MediaBrowser.MediaEncoding/Encoder/MediaEncoder.cs +++ b/MediaBrowser.MediaEncoding/Encoder/MediaEncoder.cs @@ -95,6 +95,11 @@ namespace MediaBrowser.MediaEncoding.Encoder int defaultImageExtractionTimeoutMs, bool enableEncoderFontFile, IEnvironmentInfo environmentInfo) { + if (jsonSerializer == null) + { + throw new ArgumentNullException("jsonSerializer"); + } + _logger = logger; _jsonSerializer = jsonSerializer; ConfigurationManager = configurationManager; @@ -282,6 +287,8 @@ namespace MediaBrowser.MediaEncoding.Encoder return; } + _logger.Info("Attempting to update encoder path to {0}. pathType: {1}", path ?? string.Empty, pathType ?? string.Empty); + Tuple<string, string> newPaths; if (string.Equals(pathType, "system", StringComparison.OrdinalIgnoreCase)) @@ -632,7 +639,7 @@ namespace MediaBrowser.MediaEncoding.Encoder var result = _jsonSerializer.DeserializeFromStream<InternalMediaInfoResult>(process.StandardOutput.BaseStream); - if (result.streams == null && result.format == null) + if (result == null || (result.streams == null && result.format == null)) { throw new Exception("ffprobe failed - streams and format are both null."); } |
