diff options
| author | Luke Pulverenti <luke.pulverenti@gmail.com> | 2013-04-23 20:25:49 -0400 |
|---|---|---|
| committer | Luke Pulverenti <luke.pulverenti@gmail.com> | 2013-04-23 20:25:49 -0400 |
| commit | 7839a90c1a4016acc72bd58ba5f1eadd2f559a82 (patch) | |
| tree | 9352b504d6d9d9119de60085033f68416724f2a4 /MediaBrowser.Api/Playback/BaseStreamingService.cs | |
| parent | ebd26e59f0c3fd49fee882d11286e40e108ee937 (diff) | |
added subtitle seek on extract
Diffstat (limited to 'MediaBrowser.Api/Playback/BaseStreamingService.cs')
| -rw-r--r-- | MediaBrowser.Api/Playback/BaseStreamingService.cs | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/MediaBrowser.Api/Playback/BaseStreamingService.cs b/MediaBrowser.Api/Playback/BaseStreamingService.cs index 1510dd472..cddd05197 100644 --- a/MediaBrowser.Api/Playback/BaseStreamingService.cs +++ b/MediaBrowser.Api/Playback/BaseStreamingService.cs @@ -290,7 +290,7 @@ namespace MediaBrowser.Api.Playback /// <returns>System.String.</returns> protected string GetTextSubtitleParam(Video video, MediaStream subtitleStream, long? startTimeTicks) { - var path = subtitleStream.IsExternal ? GetConvertedAssPath(video, subtitleStream) : GetExtractedAssPath(video, subtitleStream); + var path = subtitleStream.IsExternal ? GetConvertedAssPath(video, subtitleStream) : GetExtractedAssPath(video, subtitleStream, startTimeTicks); if (string.IsNullOrEmpty(path)) { @@ -299,7 +299,7 @@ namespace MediaBrowser.Api.Playback var param = string.Format(",ass='{0}'", path.Replace('\\', '/').Replace(":/", "\\:/")); - if (startTimeTicks.HasValue) + if (startTimeTicks.HasValue && subtitleStream.IsExternal) { var seconds = Convert.ToInt32(TimeSpan.FromTicks(startTimeTicks.Value).TotalSeconds); param += string.Format(",setpts=PTS-{0}/TB", seconds); @@ -313,10 +313,13 @@ namespace MediaBrowser.Api.Playback /// </summary> /// <param name="video">The video.</param> /// <param name="subtitleStream">The subtitle stream.</param> + /// <param name="startTimeTicks">The start time ticks.</param> /// <returns>System.String.</returns> - private string GetExtractedAssPath(Video video, MediaStream subtitleStream) + private string GetExtractedAssPath(Video video, MediaStream subtitleStream, long? startTimeTicks) { - var path = Kernel.Instance.FFMpegManager.GetSubtitleCachePath(video, subtitleStream.Index, ".ass"); + var offset = TimeSpan.FromTicks(startTimeTicks ?? 0); + + var path = Kernel.Instance.FFMpegManager.GetSubtitleCachePath(video, subtitleStream.Index, offset, ".ass"); if (!File.Exists(path)) { @@ -326,7 +329,7 @@ namespace MediaBrowser.Api.Playback try { - var task = MediaEncoder.ExtractTextSubtitle(inputPath, type, subtitleStream.Index, path, CancellationToken.None); + var task = MediaEncoder.ExtractTextSubtitle(inputPath, type, subtitleStream.Index, offset, path, CancellationToken.None); Task.WaitAll(task); } @@ -347,7 +350,7 @@ namespace MediaBrowser.Api.Playback /// <returns>System.String.</returns> private string GetConvertedAssPath(Video video, MediaStream subtitleStream) { - var path = Kernel.Instance.FFMpegManager.GetSubtitleCachePath(video, subtitleStream.Index, ".ass"); + var path = Kernel.Instance.FFMpegManager.GetSubtitleCachePath(video, subtitleStream.Index, null, ".ass"); if (!File.Exists(path)) { |
