From 41f7e2ab19b723a32865b868ffe489dbd36065e8 Mon Sep 17 00:00:00 2001 From: abeloin Date: Sat, 25 Jan 2014 15:27:31 -0500 Subject: Don't re-encode subtitle: ass/ssa -> ass. This fix Issue #630 : "ASS encoder supports only one ASS rectangle field". --- .../MediaEncoder/MediaEncoder.cs | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) (limited to 'MediaBrowser.Server.Implementations/MediaEncoder') diff --git a/MediaBrowser.Server.Implementations/MediaEncoder/MediaEncoder.cs b/MediaBrowser.Server.Implementations/MediaEncoder/MediaEncoder.cs index e435b1644..fddcbe53e 100644 --- a/MediaBrowser.Server.Implementations/MediaEncoder/MediaEncoder.cs +++ b/MediaBrowser.Server.Implementations/MediaEncoder/MediaEncoder.cs @@ -601,11 +601,12 @@ namespace MediaBrowser.Server.Implementations.MediaEncoder /// The input files. /// The type. /// Index of the subtitle stream. + /// if set to true, copy stream instead of converting. /// The output path. /// The cancellation token. /// Task. /// Must use inputPath list overload - public async Task ExtractTextSubtitle(string[] inputFiles, InputType type, int subtitleStreamIndex, string outputPath, CancellationToken cancellationToken) + public async Task ExtractTextSubtitle(string[] inputFiles, InputType type, int subtitleStreamIndex, bool copySubtitleStream, string outputPath, CancellationToken cancellationToken) { var semaphore = GetLock(outputPath); @@ -615,7 +616,7 @@ namespace MediaBrowser.Server.Implementations.MediaEncoder { if (!File.Exists(outputPath)) { - await ExtractTextSubtitleInternal(GetInputArgument(inputFiles, type), subtitleStreamIndex, outputPath, cancellationToken).ConfigureAwait(false); + await ExtractTextSubtitleInternal(GetInputArgument(inputFiles, type), subtitleStreamIndex, copySubtitleStream, outputPath, cancellationToken).ConfigureAwait(false); } } finally @@ -629,6 +630,7 @@ namespace MediaBrowser.Server.Implementations.MediaEncoder /// /// The input path. /// Index of the subtitle stream. + /// if set to true, copy stream instead of converting. /// The output path. /// The cancellation token. /// Task. @@ -638,7 +640,7 @@ namespace MediaBrowser.Server.Implementations.MediaEncoder /// or /// cancellationToken /// - private async Task ExtractTextSubtitleInternal(string inputPath, int subtitleStreamIndex, string outputPath, CancellationToken cancellationToken) + private async Task ExtractTextSubtitleInternal(string inputPath, int subtitleStreamIndex, bool copySubtitleStream, string outputPath, CancellationToken cancellationToken) { if (string.IsNullOrEmpty(inputPath)) { @@ -650,6 +652,12 @@ namespace MediaBrowser.Server.Implementations.MediaEncoder throw new ArgumentNullException("outputPath"); } + string processArgs = string.Format("-i {0} -map 0:{1} -an -vn -c:s ass \"{2}\"", inputPath, subtitleStreamIndex, outputPath); + + if (copySubtitleStream) + { + processArgs = string.Format("-i {0} -map 0:{1} -an -vn -c:s copy \"{2}\"", inputPath, subtitleStreamIndex, outputPath); + } var process = new Process { @@ -662,7 +670,7 @@ namespace MediaBrowser.Server.Implementations.MediaEncoder RedirectStandardError = true, FileName = FFMpegPath, - Arguments = string.Format("-i {0} -map 0:{1} -an -vn -c:s ass \"{2}\"", inputPath, subtitleStreamIndex, outputPath), + Arguments = processArgs, WindowStyle = ProcessWindowStyle.Hidden, ErrorDialog = false } -- cgit v1.2.3