update subtitle encoder to allow format passthrough
This commit is contained in:
parent
78e6d1b80f
commit
6eb5d34af1
|
@ -122,10 +122,15 @@ namespace MediaBrowser.MediaEncoding.Subtitles
|
|||
var subtitle = await GetSubtitleStream(itemId, mediaSourceId, subtitleStreamIndex, cancellationToken)
|
||||
.ConfigureAwait(false);
|
||||
|
||||
var inputFormat = subtitle.Item2;
|
||||
|
||||
if (string.Equals(inputFormat, outputFormat, StringComparison.OrdinalIgnoreCase) && TryGetWriter(outputFormat) == null)
|
||||
{
|
||||
return subtitle.Item1;
|
||||
}
|
||||
|
||||
using (var stream = subtitle.Item1)
|
||||
{
|
||||
var inputFormat = subtitle.Item2;
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user