|
|
|
@ -290,22 +290,14 @@ 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, 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(":/", "\\:/"));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
@ -347,16 +339,21 @@ 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 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);
|
|
|
|
|
}
|
|
|
|
|