The Free Software Media System - Server Backend & API
Extract subs to srt instead of ass
Luke Pulverentid92936187d2e
diff --git a/MediaBrowser.MediaEncoding/Subtitles/SubtitleEncoder.cs b/MediaBrowser.MediaEncoding/Subtitles/SubtitleEncoder.csindex 1e839c5a36..df22b5e1f7 100644--- a/MediaBrowser.MediaEncoding/Subtitles/SubtitleEncoder.cs+++ b/MediaBrowser.MediaEncoding/Subtitles/SubtitleEncoder.cs@@ -194,15 +194,17 @@ namespace MediaBrowser.MediaEncoding.SubtitlesMediaStream subtitleStream,CancellationToken cancellationToken){+ const string extractedFormat = "srt";+if (!subtitleStream.IsExternal){// Extract- var outputPath = GetSubtitleCachePath(mediaPath, subtitleStream.Index, ".ass");+ var outputPath = GetSubtitleCachePath(mediaPath, subtitleStream.Index, "." + extractedFormat);await ExtractTextSubtitle(inputFiles, protocol, subtitleStream.Index, false, outputPath, cancellationToken).ConfigureAwait(false);- return new Tuple<string, string>(outputPath, "ass");+ return new Tuple<string, string>(outputPath, extractedFormat);}var currentFormat = (Path.GetExtension(subtitleStream.Path) ?? subtitleStream.Codec)@@ -211,12 +213,12 @@ namespace MediaBrowser.MediaEncoding.Subtitlesif (GetReader(currentFormat, false) == null){// Convert- var outputPath = GetSubtitleCachePath(mediaPath, subtitleStream.Index, ".ass");+ var outputPath = GetSubtitleCachePath(mediaPath, subtitleStream.Index, "." + extractedFormat);- await ConvertTextSubtitleToAss(subtitleStream.Path, outputPath, subtitleStream.Language, cancellationToken)+ await ConvertTextSubtitleToSrt(subtitleStream.Path, outputPath, subtitleStream.Language, cancellationToken).ConfigureAwait(false);- return new Tuple<string, string>(outputPath, "ass");+ return new Tuple<string, string>(outputPath, extractedFormat);}return new Tuple<string, string>(subtitleStream.Path, currentFormat);@@ -303,14 +305,14 @@ namespace MediaBrowser.MediaEncoding.Subtitles}/// <summary>- /// Converts the text subtitle to ass.+ /// Converts the text subtitle to SRT./// </summary>/// <param name="inputPath">The input path.</param>/// <param name="outputPath">The output path.</param>/// <param name="language">The language.</param>/// <param name="cancellationToken">The cancellation token.</param>/// <returns>Task.</returns>- public async Task ConvertTextSubtitleToAss(string inputPath, string outputPath, string language,+ public async Task ConvertTextSubtitleToSrt(string inputPath, string outputPath, string language,CancellationToken cancellationToken){var semaphore = GetLock(outputPath);@@ -321,7 +323,7 @@ namespace MediaBrowser.MediaEncoding.Subtitles{if (!File.Exists(outputPath)){- await ConvertTextSubtitleToAssInternal(inputPath, outputPath, language).ConfigureAwait(false);+ await ConvertTextSubtitleToSrtInternal(inputPath, outputPath, language).ConfigureAwait(false);}}finally@@ -331,17 +333,19 @@ namespace MediaBrowser.MediaEncoding.Subtitles}/// <summary>- /// Converts the text subtitle to ass.+ /// Converts the text subtitle to SRT internal./// </summary>/// <param name="inputPath">The input path.</param>/// <param name="outputPath">The output path.</param>/// <param name="language">The language.</param>/// <returns>Task.</returns>- /// <exception cref="System.ArgumentNullException">inputPath+ /// <exception cref="System.ArgumentNullException">+ /// inputPath/// or- /// outputPath</exception>+ /// outputPath+ /// </exception>/// <exception cref="System.ApplicationException"></exception>- private async Task ConvertTextSubtitleToAssInternal(string inputPath, string outputPath, string language)+ private async Task ConvertTextSubtitleToSrtInternal(string inputPath, string outputPath, string language){if (string.IsNullOrEmpty(inputPath)){@@ -375,7 +379,7 @@ namespace MediaBrowser.MediaEncoding.SubtitlesCreateNoWindow = true,UseShellExecute = false,FileName = _mediaEncoder.EncoderPath,- Arguments = string.Format("{0} -i \"{1}\" -c:s ass \"{2}\"", encodingParam, inputPath, outputPath),+ Arguments = string.Format("{0} -i \"{1}\" -c:s srt \"{2}\"", encodingParam, inputPath, outputPath),WindowStyle = ProcessWindowStyle.Hidden,ErrorDialog = false@@ -529,7 +533,7 @@ namespace MediaBrowser.MediaEncoding.SubtitlesDirectory.CreateDirectory(Path.GetDirectoryName(outputPath));- var processArgs = string.Format("-i {0} -map 0:{1} -an -vn -c:s ass \"{2}\"", inputPath,+ var processArgs = string.Format("-i {0} -map 0:{1} -an -vn -c:s srt \"{2}\"", inputPath,subtitleStreamIndex, outputPath);if (copySubtitleStream)