From fc1bee30a62e2e31682809c8245a117f7ecbddd5 Mon Sep 17 00:00:00 2001 From: David Schulte Date: Mon, 15 Jul 2024 14:48:09 +0200 Subject: Allow streaming of raw PGS subtitles without transcoding (#12056) --- MediaBrowser.Model/Entities/MediaStream.cs | 33 ++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) (limited to 'MediaBrowser.Model/Entities') diff --git a/MediaBrowser.Model/Entities/MediaStream.cs b/MediaBrowser.Model/Entities/MediaStream.cs index e1082adead..9044c0524e 100644 --- a/MediaBrowser.Model/Entities/MediaStream.cs +++ b/MediaBrowser.Model/Entities/MediaStream.cs @@ -585,6 +585,31 @@ namespace MediaBrowser.Model.Entities } } + public bool IsPgsSubtitleStream + { + get + { + if (Type != MediaStreamType.Subtitle) + { + return false; + } + + if (string.IsNullOrEmpty(Codec) && !IsExternal) + { + return false; + } + + return IsPgsFormat(Codec); + } + } + + /// + /// Gets a value indicating whether this is a subtitle steam that is extractable by ffmpeg. + /// All text-based and pgs subtitles can be extracted. + /// + /// true if this is a extractable subtitle steam otherwise, false. + public bool IsExtractableSubtitleStream => IsTextSubtitleStream || IsPgsSubtitleStream; + /// /// Gets or sets a value indicating whether [supports external stream]. /// @@ -666,6 +691,14 @@ namespace MediaBrowser.Model.Entities && !string.Equals(codec, "sub", StringComparison.OrdinalIgnoreCase)); } + public static bool IsPgsFormat(string format) + { + string codec = format ?? string.Empty; + + return codec.Contains("pgs", StringComparison.OrdinalIgnoreCase) + || string.Equals(codec, "sup", StringComparison.OrdinalIgnoreCase); + } + public bool SupportsSubtitleConversionTo(string toCodec) { if (!IsTextSubtitleStream) -- cgit v1.2.3