diff --git a/MediaBrowser.Server.Implementations/MediaEncoder/MediaEncoder.cs b/MediaBrowser.Server.Implementations/MediaEncoder/MediaEncoder.cs index 9f29b2db1..cee219ad7 100644 --- a/MediaBrowser.Server.Implementations/MediaEncoder/MediaEncoder.cs +++ b/MediaBrowser.Server.Implementations/MediaEncoder/MediaEncoder.cs @@ -379,7 +379,7 @@ namespace MediaBrowser.Server.Implementations.MediaEncoder throw; } - + try { Task standardErrorReadTask = null; @@ -455,8 +455,11 @@ namespace MediaBrowser.Server.Implementations.MediaEncoder return result; } + /// + /// The us culture + /// protected readonly CultureInfo UsCulture = new CultureInfo("en-US"); - + /// /// Adds the chapters. /// @@ -615,13 +618,14 @@ namespace MediaBrowser.Server.Implementations.MediaEncoder /// The input files. /// The type. /// Index of the subtitle stream. + /// The offset. /// The output path. /// The cancellation token. /// Task. /// Must use inputPath list overload - public Task ExtractTextSubtitle(string[] inputFiles, InputType type, int subtitleStreamIndex, string outputPath, CancellationToken cancellationToken) + public Task ExtractTextSubtitle(string[] inputFiles, InputType type, int subtitleStreamIndex, TimeSpan offset, string outputPath, CancellationToken cancellationToken) { - return ExtractTextSubtitleInternal(GetInputArgument(inputFiles, type), subtitleStreamIndex, outputPath, cancellationToken); + return ExtractTextSubtitleInternal(GetInputArgument(inputFiles, type), subtitleStreamIndex, offset, outputPath, cancellationToken); } /// @@ -629,6 +633,7 @@ namespace MediaBrowser.Server.Implementations.MediaEncoder /// /// The input path. /// Index of the subtitle stream. + /// The offset. /// The output path. /// The cancellation token. /// Task. @@ -638,7 +643,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, TimeSpan offset, string outputPath, CancellationToken cancellationToken) { if (string.IsNullOrEmpty(inputPath)) { @@ -655,6 +660,8 @@ namespace MediaBrowser.Server.Implementations.MediaEncoder throw new ArgumentNullException("cancellationToken"); } + var offsetParam = offset.Ticks > 0 ? "-ss " + offset.TotalSeconds + " " : string.Empty; + var process = new Process { StartInfo = new ProcessStartInfo @@ -662,7 +669,7 @@ namespace MediaBrowser.Server.Implementations.MediaEncoder CreateNoWindow = true, UseShellExecute = false, FileName = FFMpegPath, - Arguments = string.Format("-i {0} -map 0:{1} -an -vn -c:s ass \"{2}\"", inputPath, subtitleStreamIndex, outputPath), + Arguments = string.Format("{0}-i {1} -map 0:{2} -an -vn -c:s ass \"{3}\"", offsetParam, inputPath, subtitleStreamIndex, outputPath), WindowStyle = ProcessWindowStyle.Hidden, ErrorDialog = false }