fixed subtitle conversions

This commit is contained in:
Luke Pulverenti 2013-05-01 12:56:36 -04:00
parent 7f5783988a
commit f9ec1ce37f
2 changed files with 8 additions and 5 deletions

View File

@ -348,9 +348,7 @@ namespace MediaBrowser.Api.Playback
/// <returns>System.String.</returns> /// <returns>System.String.</returns>
private string GetConvertedAssPath(Video video, MediaStream subtitleStream, long? startTimeTicks, bool performConversion) private string GetConvertedAssPath(Video video, MediaStream subtitleStream, long? startTimeTicks, bool performConversion)
{ {
var offset = startTimeTicks.HasValue var offset = TimeSpan.FromTicks(startTimeTicks ?? 0);
? TimeSpan.FromTicks(startTimeTicks.Value)
: TimeSpan.FromTicks(0);
var path = Kernel.Instance.FFMpegManager.GetSubtitleCachePath(video, subtitleStream.Index, offset, ".ass"); var path = Kernel.Instance.FFMpegManager.GetSubtitleCachePath(video, subtitleStream.Index, offset, ".ass");

View File

@ -554,6 +554,8 @@ namespace MediaBrowser.Server.Implementations.MediaEncoder
throw new ArgumentNullException("outputPath"); throw new ArgumentNullException("outputPath");
} }
var offsetParam = offset.Ticks > 0 ? "-ss " + offset.TotalSeconds + " " : string.Empty;
var process = new Process var process = new Process
{ {
StartInfo = new ProcessStartInfo StartInfo = new ProcessStartInfo
@ -564,7 +566,7 @@ namespace MediaBrowser.Server.Implementations.MediaEncoder
CreateNoWindow = true, CreateNoWindow = true,
UseShellExecute = false, UseShellExecute = false,
FileName = FFMpegPath, FileName = FFMpegPath,
Arguments = string.Format("-i \"{0}\" \"{1}\"", inputPath, outputPath), Arguments = string.Format("{0}-i \"{1}\" \"{2}\"", offsetParam, inputPath, outputPath),
WindowStyle = ProcessWindowStyle.Hidden, WindowStyle = ProcessWindowStyle.Hidden,
ErrorDialog = false ErrorDialog = false
} }
@ -593,7 +595,7 @@ namespace MediaBrowser.Server.Implementations.MediaEncoder
throw; throw;
} }
process.StandardError.BaseStream.CopyToAsync(logFileStream); var logTask = process.StandardError.BaseStream.CopyToAsync(logFileStream);
var ranToCompletion = process.WaitForExit(60000); var ranToCompletion = process.WaitForExit(60000);
@ -606,6 +608,8 @@ namespace MediaBrowser.Server.Implementations.MediaEncoder
process.Kill(); process.Kill();
process.WaitForExit(1000); process.WaitForExit(1000);
await logTask.ConfigureAwait(false);
} }
catch (Win32Exception ex) catch (Win32Exception ex)
{ {
@ -621,6 +625,7 @@ namespace MediaBrowser.Server.Implementations.MediaEncoder
} }
finally finally
{ {
logFileStream.Dispose(); logFileStream.Dispose();
_subtitleExtractionResourcePool.Release(); _subtitleExtractionResourcePool.Release();
} }