Bladeren bron

fixed subtitle conversions

Luke Pulverenti 12 jaren geleden
bovenliggende
commit
f9ec1ce37f

+ 1 - 3
MediaBrowser.Api/Playback/BaseStreamingService.cs

@@ -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
-                          ? TimeSpan.FromTicks(startTimeTicks.Value)
-                          : TimeSpan.FromTicks(0);
+            var offset = TimeSpan.FromTicks(startTimeTicks ?? 0);
 
 
             var path = Kernel.Instance.FFMpegManager.GetSubtitleCachePath(video, subtitleStream.Index, offset, ".ass");
             var path = Kernel.Instance.FFMpegManager.GetSubtitleCachePath(video, subtitleStream.Index, offset, ".ass");
 
 

+ 7 - 2
MediaBrowser.Server.Implementations/MediaEncoder/MediaEncoder.cs

@@ -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();
                 }
                 }