diff options
| author | Luke Pulverenti <luke.pulverenti@gmail.com> | 2013-05-01 12:56:36 -0400 |
|---|---|---|
| committer | Luke Pulverenti <luke.pulverenti@gmail.com> | 2013-05-01 12:56:36 -0400 |
| commit | f9ec1ce37f3a87fc5845a9a12282a444858fd3f0 (patch) | |
| tree | a757c492b7ad2442f5dd524665dbff3aacf94833 | |
| parent | 7f5783988a7194452760a3ff0a06a816c057456f (diff) | |
fixed subtitle conversions
| -rw-r--r-- | MediaBrowser.Api/Playback/BaseStreamingService.cs | 4 | ||||
| -rw-r--r-- | MediaBrowser.Server.Implementations/MediaEncoder/MediaEncoder.cs | 9 |
2 files changed, 8 insertions, 5 deletions
diff --git a/MediaBrowser.Api/Playback/BaseStreamingService.cs b/MediaBrowser.Api/Playback/BaseStreamingService.cs index 81ab7c4eb..30700ad4c 100644 --- a/MediaBrowser.Api/Playback/BaseStreamingService.cs +++ b/MediaBrowser.Api/Playback/BaseStreamingService.cs @@ -348,9 +348,7 @@ namespace MediaBrowser.Api.Playback /// <returns>System.String.</returns> private string GetConvertedAssPath(Video video, MediaStream subtitleStream, long? startTimeTicks, bool performConversion) { - var offset = startTimeTicks.HasValue - ? TimeSpan.FromTicks(startTimeTicks.Value) - : TimeSpan.FromTicks(0); + var offset = TimeSpan.FromTicks(startTimeTicks ?? 0); var path = Kernel.Instance.FFMpegManager.GetSubtitleCachePath(video, subtitleStream.Index, offset, ".ass"); diff --git a/MediaBrowser.Server.Implementations/MediaEncoder/MediaEncoder.cs b/MediaBrowser.Server.Implementations/MediaEncoder/MediaEncoder.cs index 1312d49ce..3d4da1e15 100644 --- a/MediaBrowser.Server.Implementations/MediaEncoder/MediaEncoder.cs +++ b/MediaBrowser.Server.Implementations/MediaEncoder/MediaEncoder.cs @@ -554,6 +554,8 @@ namespace MediaBrowser.Server.Implementations.MediaEncoder throw new ArgumentNullException("outputPath"); } + var offsetParam = offset.Ticks > 0 ? "-ss " + offset.TotalSeconds + " " : string.Empty; + var process = new Process { StartInfo = new ProcessStartInfo @@ -564,7 +566,7 @@ namespace MediaBrowser.Server.Implementations.MediaEncoder CreateNoWindow = true, UseShellExecute = false, FileName = FFMpegPath, - Arguments = string.Format("-i \"{0}\" \"{1}\"", inputPath, outputPath), + Arguments = string.Format("{0}-i \"{1}\" \"{2}\"", offsetParam, inputPath, outputPath), WindowStyle = ProcessWindowStyle.Hidden, ErrorDialog = false } @@ -593,7 +595,7 @@ namespace MediaBrowser.Server.Implementations.MediaEncoder throw; } - process.StandardError.BaseStream.CopyToAsync(logFileStream); + var logTask = process.StandardError.BaseStream.CopyToAsync(logFileStream); var ranToCompletion = process.WaitForExit(60000); @@ -606,6 +608,8 @@ namespace MediaBrowser.Server.Implementations.MediaEncoder process.Kill(); process.WaitForExit(1000); + + await logTask.ConfigureAwait(false); } catch (Win32Exception ex) { @@ -621,6 +625,7 @@ namespace MediaBrowser.Server.Implementations.MediaEncoder } finally { + logFileStream.Dispose(); _subtitleExtractionResourcePool.Release(); } |
