diff --git a/MediaBrowser.Api/Playback/BaseStreamingService.cs b/MediaBrowser.Api/Playback/BaseStreamingService.cs
index cddd051971..6cc0b92414 100644
--- a/MediaBrowser.Api/Playback/BaseStreamingService.cs
+++ b/MediaBrowser.Api/Playback/BaseStreamingService.cs
@@ -290,22 +290,14 @@ namespace MediaBrowser.Api.Playback
/// System.String.
protected string GetTextSubtitleParam(Video video, MediaStream subtitleStream, long? startTimeTicks)
{
- var path = subtitleStream.IsExternal ? GetConvertedAssPath(video, subtitleStream) : GetExtractedAssPath(video, subtitleStream, startTimeTicks);
+ var path = subtitleStream.IsExternal ? GetConvertedAssPath(video, subtitleStream, startTimeTicks) : GetExtractedAssPath(video, subtitleStream, startTimeTicks);
if (string.IsNullOrEmpty(path))
{
return string.Empty;
}
- var param = string.Format(",ass='{0}'", path.Replace('\\', '/').Replace(":/", "\\:/"));
-
- if (startTimeTicks.HasValue && subtitleStream.IsExternal)
- {
- var seconds = Convert.ToInt32(TimeSpan.FromTicks(startTimeTicks.Value).TotalSeconds);
- param += string.Format(",setpts=PTS-{0}/TB", seconds);
- }
-
- return param;
+ return string.Format(",ass='{0}'", path.Replace('\\', '/').Replace(":/", "\\:/"));
}
///
@@ -347,16 +339,21 @@ namespace MediaBrowser.Api.Playback
///
/// The video.
/// The subtitle stream.
+ /// The start time ticks.
/// System.String.
- private string GetConvertedAssPath(Video video, MediaStream subtitleStream)
+ private string GetConvertedAssPath(Video video, MediaStream subtitleStream, long? startTimeTicks)
{
- var path = Kernel.Instance.FFMpegManager.GetSubtitleCachePath(video, subtitleStream.Index, null, ".ass");
+ var offset = startTimeTicks.HasValue
+ ? TimeSpan.FromTicks(startTimeTicks.Value)
+ : TimeSpan.FromTicks(0);
+
+ var path = Kernel.Instance.FFMpegManager.GetSubtitleCachePath(video, subtitleStream.Index, offset, ".ass");
if (!File.Exists(path))
{
try
{
- var task = MediaEncoder.ConvertTextSubtitleToAss(subtitleStream.Path, path, CancellationToken.None);
+ var task = MediaEncoder.ConvertTextSubtitleToAss(subtitleStream.Path, path, offset, CancellationToken.None);
Task.WaitAll(task);
}
diff --git a/MediaBrowser.Common/MediaInfo/IMediaEncoder.cs b/MediaBrowser.Common/MediaInfo/IMediaEncoder.cs
index 8dc18067c6..6d606e6847 100644
--- a/MediaBrowser.Common/MediaInfo/IMediaEncoder.cs
+++ b/MediaBrowser.Common/MediaInfo/IMediaEncoder.cs
@@ -49,9 +49,10 @@ namespace MediaBrowser.Common.MediaInfo
///
/// The input path.
/// The output path.
+ /// The offset.
/// The cancellation token.
/// Task.
- Task ConvertTextSubtitleToAss(string inputPath, string outputPath, CancellationToken cancellationToken);
+ Task ConvertTextSubtitleToAss(string inputPath, string outputPath, TimeSpan offset, CancellationToken cancellationToken);
///
/// Gets the media info.
diff --git a/MediaBrowser.Server.Implementations/MediaEncoder/MediaEncoder.cs b/MediaBrowser.Server.Implementations/MediaEncoder/MediaEncoder.cs
index eda2506d15..b52b0c93c7 100644
--- a/MediaBrowser.Server.Implementations/MediaEncoder/MediaEncoder.cs
+++ b/MediaBrowser.Server.Implementations/MediaEncoder/MediaEncoder.cs
@@ -535,13 +535,14 @@ namespace MediaBrowser.Server.Implementations.MediaEncoder
///
/// The input path.
/// The output path.
+ /// The offset.
/// The cancellation token.
/// Task.
/// inputPath
/// or
/// outputPath
///
- public async Task ConvertTextSubtitleToAss(string inputPath, string outputPath, CancellationToken cancellationToken)
+ public async Task ConvertTextSubtitleToAss(string inputPath, string outputPath, TimeSpan offset, CancellationToken cancellationToken)
{
if (string.IsNullOrEmpty(inputPath))
{