|
|
|
@ -122,10 +122,15 @@ namespace MediaBrowser.MediaEncoding.Subtitles
|
|
|
|
|
var subtitle = await GetSubtitleStream(itemId, mediaSourceId, subtitleStreamIndex, cancellationToken)
|
|
|
|
|
.ConfigureAwait(false);
|
|
|
|
|
|
|
|
|
|
using (var stream = subtitle.Item1)
|
|
|
|
|
var inputFormat = subtitle.Item2;
|
|
|
|
|
|
|
|
|
|
if (string.Equals(inputFormat, outputFormat, StringComparison.OrdinalIgnoreCase) && TryGetWriter(outputFormat) == null)
|
|
|
|
|
{
|
|
|
|
|
var inputFormat = subtitle.Item2;
|
|
|
|
|
return subtitle.Item1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
using (var stream = subtitle.Item1)
|
|
|
|
|
{
|
|
|
|
|
return await ConvertSubtitles(stream, inputFormat, outputFormat, startTimeTicks, endTimeTicks, cancellationToken).ConfigureAwait(false);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -288,7 +293,7 @@ namespace MediaBrowser.MediaEncoding.Subtitles
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private ISubtitleWriter GetWriter(string format)
|
|
|
|
|
private ISubtitleWriter TryGetWriter(string format)
|
|
|
|
|
{
|
|
|
|
|
if (string.IsNullOrEmpty(format))
|
|
|
|
|
{
|
|
|
|
@ -312,6 +317,18 @@ namespace MediaBrowser.MediaEncoding.Subtitles
|
|
|
|
|
return new TtmlWriter();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private ISubtitleWriter GetWriter(string format)
|
|
|
|
|
{
|
|
|
|
|
var writer = TryGetWriter(format);
|
|
|
|
|
|
|
|
|
|
if (writer != null)
|
|
|
|
|
{
|
|
|
|
|
return writer;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
throw new ArgumentException("Unsupported format: " + format);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|