The Free Software Media System - Server Backend & API
adjust subtitle extraction
Luke Pulverenti9d36f518182b
diff --git a/MediaBrowser.MediaEncoding/Subtitles/SubtitleEncoder.cs b/MediaBrowser.MediaEncoding/Subtitles/SubtitleEncoder.csindex 87d706a16a..7a3a7d2d0c 100644--- a/MediaBrowser.MediaEncoding/Subtitles/SubtitleEncoder.cs+++ b/MediaBrowser.MediaEncoding/Subtitles/SubtitleEncoder.cs@@ -194,17 +194,38 @@ namespace MediaBrowser.MediaEncoding.SubtitlesMediaStream subtitleStream,CancellationToken cancellationToken){- const string extractedFormat = "srt";-if (!subtitleStream.IsExternal){+ string outputFormat;+ string outputCodec;++ if (string.Equals(subtitleStream.Codec, "ass", StringComparison.OrdinalIgnoreCase))+ {+ // Extract+ outputCodec = "copy";+ outputFormat = "ass";+ }+ else if (string.Equals(subtitleStream.Codec, "subrip", StringComparison.OrdinalIgnoreCase) ||+ string.Equals(subtitleStream.Codec, "srt", StringComparison.OrdinalIgnoreCase))+ {+ // Extract+ outputCodec = "copy";+ outputFormat = "srt";+ }+ else+ {+ // Extract+ outputCodec = "srt";+ outputFormat = "srt";+ }+// Extract- var outputPath = GetSubtitleCachePath(mediaPath, subtitleStream.Index, "." + extractedFormat);+ var outputPath = GetSubtitleCachePath(mediaPath, subtitleStream.Index, "." + outputFormat);- await ExtractTextSubtitle(inputFiles, protocol, subtitleStream.Index, "srt", outputPath, cancellationToken)+ await ExtractTextSubtitle(inputFiles, protocol, subtitleStream.Index, outputCodec, outputPath, cancellationToken).ConfigureAwait(false);- return new Tuple<string, string>(outputPath, extractedFormat);+ return new Tuple<string, string>(outputPath, outputFormat);}var currentFormat = (Path.GetExtension(subtitleStream.Path) ?? subtitleStream.Codec)@@ -213,12 +234,12 @@ namespace MediaBrowser.MediaEncoding.Subtitlesif (GetReader(currentFormat, false) == null){// Convert- var outputPath = GetSubtitleCachePath(mediaPath, subtitleStream.Index, "." + extractedFormat);+ var outputPath = GetSubtitleCachePath(mediaPath, subtitleStream.Index, ".srt");await ConvertTextSubtitleToSrt(subtitleStream.Path, outputPath, subtitleStream.Language, cancellationToken).ConfigureAwait(false);- return new Tuple<string, string>(outputPath, extractedFormat);+ return new Tuple<string, string>(outputPath, "srt");}return new Tuple<string, string>(subtitleStream.Path, currentFormat);