diff options
Diffstat (limited to 'MediaBrowser.MediaEncoding')
5 files changed, 65 insertions, 55 deletions
diff --git a/MediaBrowser.MediaEncoding/Encoder/EncoderValidator.cs b/MediaBrowser.MediaEncoding/Encoder/EncoderValidator.cs index b37e783b8..9c1189f6c 100644 --- a/MediaBrowser.MediaEncoding/Encoder/EncoderValidator.cs +++ b/MediaBrowser.MediaEncoding/Encoder/EncoderValidator.cs @@ -90,6 +90,7 @@ namespace MediaBrowser.MediaEncoding.Encoder var required = new[] { "h264_qsv", + "hevc_qsv", "mpeg2_qsv", "vc1_qsv" }; @@ -134,9 +135,13 @@ namespace MediaBrowser.MediaEncoding.Encoder "libvorbis", "srt", "h264_nvenc", + "hevc_nvenc", "h264_qsv", + "hevc_qsv", "h264_omx", + "hevc_omx", "h264_vaapi", + "hevc_vaapi", "ac3" }; @@ -205,4 +210,4 @@ namespace MediaBrowser.MediaEncoding.Encoder } } } -}
\ No newline at end of file +} diff --git a/MediaBrowser.MediaEncoding/Encoder/EncodingUtils.cs b/MediaBrowser.MediaEncoding/Encoder/EncodingUtils.cs index e547f2fae..498df214f 100644 --- a/MediaBrowser.MediaEncoding/Encoder/EncodingUtils.cs +++ b/MediaBrowser.MediaEncoding/Encoder/EncodingUtils.cs @@ -61,15 +61,5 @@ namespace MediaBrowser.MediaEncoding.Encoder // Quotes are valid path characters in linux and they need to be escaped here with a leading \ return path.Replace("\"", "\\\""); } - - public static string GetProbeSizeArgument(int numInputFiles) - { - return numInputFiles > 1 ? "-probesize 1G" : ""; - } - - public static string GetAnalyzeDurationArgument(int numInputFiles) - { - return numInputFiles > 1 ? "-analyzeduration 200M" : ""; - } } } diff --git a/MediaBrowser.MediaEncoding/Encoder/MediaEncoder.cs b/MediaBrowser.MediaEncoding/Encoder/MediaEncoder.cs index e7737b6a6..580f5c615 100644 --- a/MediaBrowser.MediaEncoding/Encoder/MediaEncoder.cs +++ b/MediaBrowser.MediaEncoding/Encoder/MediaEncoder.cs @@ -523,17 +523,17 @@ namespace MediaBrowser.MediaEncoding.Encoder var inputFiles = MediaEncoderHelpers.GetInputArgument(FileSystem, request.InputPath, request.Protocol, request.MountedIso, request.PlayableStreamFileNames); - var probeSize = EncodingUtils.GetProbeSizeArgument(inputFiles.Length); + var probeSize = EncodingHelper.GetProbeSizeArgument(inputFiles.Length); string analyzeDuration; - if (request.AnalyzeDurationSections > 0) + if (request.AnalyzeDurationMs > 0) { analyzeDuration = "-analyzeduration " + - (request.AnalyzeDurationSections * 1000000).ToString(CultureInfo.InvariantCulture); + (request.AnalyzeDurationMs * 1000).ToString(CultureInfo.InvariantCulture); } else { - analyzeDuration = EncodingUtils.GetAnalyzeDurationArgument(inputFiles.Length); + analyzeDuration = EncodingHelper.GetAnalyzeDurationArgument(inputFiles.Length); } probeSize = probeSize + " " + analyzeDuration; @@ -558,31 +558,6 @@ namespace MediaBrowser.MediaEncoding.Encoder } /// <summary> - /// Gets the probe size argument. - /// </summary> - /// <param name="inputFiles">The input files.</param> - /// <param name="protocol">The protocol.</param> - /// <returns>System.String.</returns> - public string GetProbeSizeAndAnalyzeDurationArgument(string[] inputFiles, MediaProtocol protocol) - { - var results = new List<string>(); - - var probeSize = EncodingUtils.GetProbeSizeArgument(inputFiles.Length); - var analyzeDuration = EncodingUtils.GetAnalyzeDurationArgument(inputFiles.Length); - - if (!string.IsNullOrWhiteSpace(probeSize)) - { - results.Add(probeSize); - } - - if (!string.IsNullOrWhiteSpace(analyzeDuration)) - { - results.Add(analyzeDuration); - } - return string.Join(" ", results.ToArray()); - } - - /// <summary> /// Gets the media info internal. /// </summary> /// <returns>Task{MediaInfoResult}.</returns> @@ -984,11 +959,17 @@ namespace MediaBrowser.MediaEncoding.Encoder var args = useIFrame ? string.Format("-i {0}{3} -threads 0 -v quiet -vframes 1 -vf \"{2}{4}\" -f image2 \"{1}\"", inputPath, tempExtractPath, vf, mapArg, thumbnail) : string.Format("-i {0}{3} -threads 0 -v quiet -vframes 1 -vf \"{2}\" -f image2 \"{1}\"", inputPath, tempExtractPath, vf, mapArg); - var probeSize = GetProbeSizeAndAnalyzeDurationArgument(new[] { inputPath }, protocol); + var probeSizeArgument = EncodingHelper.GetProbeSizeArgument(1); + var analyzeDurationArgument = EncodingHelper.GetAnalyzeDurationArgument(1); + + if (!string.IsNullOrWhiteSpace(probeSizeArgument)) + { + args = probeSizeArgument + " " + args; + } - if (!string.IsNullOrEmpty(probeSize)) + if (!string.IsNullOrWhiteSpace(analyzeDurationArgument)) { - args = probeSize + " " + args; + args = analyzeDurationArgument + " " + args; } if (offset.HasValue) @@ -1092,11 +1073,17 @@ namespace MediaBrowser.MediaEncoding.Encoder var args = string.Format("-i {0} -threads 0 -v quiet -vf \"{2}\" -f image2 \"{1}\"", inputArgument, outputPath, vf); - var probeSize = GetProbeSizeAndAnalyzeDurationArgument(new[] { inputArgument }, protocol); + var probeSizeArgument = EncodingHelper.GetProbeSizeArgument(1); + var analyzeDurationArgument = EncodingHelper.GetAnalyzeDurationArgument(1); + + if (!string.IsNullOrWhiteSpace(probeSizeArgument)) + { + args = probeSizeArgument + " " + args; + } - if (!string.IsNullOrEmpty(probeSize)) + if (!string.IsNullOrWhiteSpace(analyzeDurationArgument)) { - args = probeSize + " " + args; + args = analyzeDurationArgument + " " + args; } var process = _processFactory.Create(new ProcessOptions diff --git a/MediaBrowser.MediaEncoding/Probing/ProbeResultNormalizer.cs b/MediaBrowser.MediaEncoding/Probing/ProbeResultNormalizer.cs index 256c38597..7927ddb6a 100644 --- a/MediaBrowser.MediaEncoding/Probing/ProbeResultNormalizer.cs +++ b/MediaBrowser.MediaEncoding/Probing/ProbeResultNormalizer.cs @@ -558,13 +558,36 @@ namespace MediaBrowser.MediaEncoding.Probing ? MediaStreamType.EmbeddedImage : MediaStreamType.Video; + stream.AverageFrameRate = GetFrameRate(streamInfo.avg_frame_rate); + stream.RealFrameRate = GetFrameRate(streamInfo.r_frame_rate); + + if (isAudio || string.Equals(stream.Codec, "gif", StringComparison.OrdinalIgnoreCase) || + string.Equals(stream.Codec, "png", StringComparison.OrdinalIgnoreCase)) + { + stream.Type = MediaStreamType.EmbeddedImage; + } + else if (string.Equals(stream.Codec, "mjpeg", StringComparison.OrdinalIgnoreCase)) + { + // How to differentiate between video and embedded image? + // The only difference I've seen thus far is presence of codec tag, also embedded images have high (unusual) framerates + if (!string.IsNullOrWhiteSpace(stream.CodecTag)) + { + stream.Type = MediaStreamType.Video; + } + else + { + stream.Type = MediaStreamType.EmbeddedImage; + } + } + else + { + stream.Type = MediaStreamType.Video; + } + stream.Width = streamInfo.width; stream.Height = streamInfo.height; stream.AspectRatio = GetAspectRatio(streamInfo); - stream.AverageFrameRate = GetFrameRate(streamInfo.avg_frame_rate); - stream.RealFrameRate = GetFrameRate(streamInfo.r_frame_rate); - if (streamInfo.bits_per_sample > 0) { stream.BitDepth = streamInfo.bits_per_sample; diff --git a/MediaBrowser.MediaEncoding/Subtitles/SubtitleEncoder.cs b/MediaBrowser.MediaEncoding/Subtitles/SubtitleEncoder.cs index ca22dac2d..4a1bf5305 100644 --- a/MediaBrowser.MediaEncoding/Subtitles/SubtitleEncoder.cs +++ b/MediaBrowser.MediaEncoding/Subtitles/SubtitleEncoder.cs @@ -734,6 +734,16 @@ namespace MediaBrowser.MediaEncoding.Subtitles } } + var charsetFromLanguage = string.IsNullOrWhiteSpace(language) + ? null + : GetSubtitleFileCharacterSetFromLanguage(language); + + // This assumption should only be made for external subtitles + if (!string.IsNullOrWhiteSpace(charsetFromLanguage) && !string.Equals(charsetFromLanguage, "windows-1252", StringComparison.OrdinalIgnoreCase)) + { + return charsetFromLanguage; + } + var charset = await DetectCharset(path, language, protocol, cancellationToken).ConfigureAwait(false); if (!string.IsNullOrWhiteSpace(charset)) @@ -746,12 +756,7 @@ namespace MediaBrowser.MediaEncoding.Subtitles return charset; } - if (!string.IsNullOrWhiteSpace(language)) - { - return GetSubtitleFileCharacterSetFromLanguage(language); - } - - return null; + return charsetFromLanguage; } public string GetSubtitleFileCharacterSetFromLanguage(string language) |
