Skip to content

Commit

Permalink
Backport pull request jellyfin#12149 from jellyfin/release-10.9.z
Browse files Browse the repository at this point in the history
Fix MicroDVD being recognized as DVDSUB subtitles

Original-merge: 6010bc0

Merged-by: crobibero <[email protected]>

Backported-by: Joshua M. Boniface <[email protected]>
  • Loading branch information
nyanmisaka authored and joshuaboniface committed Jun 23, 2024
1 parent 81e38e7 commit d37c5d8
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 15 deletions.
4 changes: 2 additions & 2 deletions MediaBrowser.Controller/MediaEncoding/EncodingHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1209,8 +1209,8 @@ public string GetInputArgument(EncodingJobInfo state, EncodingOptions options, s
var subtitlePath = state.SubtitleStream.Path;
var subtitleExtension = Path.GetExtension(subtitlePath.AsSpan());

if (subtitleExtension.Equals(".sub", StringComparison.OrdinalIgnoreCase)
|| subtitleExtension.Equals(".sup", StringComparison.OrdinalIgnoreCase))
// dvdsub/vobsub graphical subtitles use .sub+.idx pairs
if (subtitleExtension.Equals(".sub", StringComparison.OrdinalIgnoreCase))
{
var idxFile = Path.ChangeExtension(subtitlePath, ".idx");
if (File.Exists(idxFile))
Expand Down
14 changes: 9 additions & 5 deletions MediaBrowser.MediaEncoding/Probing/ProbeResultNormalizer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -624,15 +624,19 @@ private string NormalizeSubtitleCodec(string codec)
{
if (string.Equals(codec, "dvb_subtitle", StringComparison.OrdinalIgnoreCase))
{
codec = "dvbsub";
codec = "DVBSUB";
}
else if ((codec ?? string.Empty).Contains("PGS", StringComparison.OrdinalIgnoreCase))
else if (string.Equals(codec, "dvb_teletext", StringComparison.OrdinalIgnoreCase))
{
codec = "PGSSUB";
codec = "DVBTXT";
}
else if ((codec ?? string.Empty).Contains("DVD", StringComparison.OrdinalIgnoreCase))
else if (string.Equals(codec, "dvd_subtitle", StringComparison.OrdinalIgnoreCase))
{
codec = "DVDSUB";
codec = "DVDSUB"; // .sub+.idx
}
else if (string.Equals(codec, "hdmv_pgs_subtitle", StringComparison.OrdinalIgnoreCase))
{
codec = "PGSSUB"; // .sup
}

return codec;
Expand Down
16 changes: 8 additions & 8 deletions MediaBrowser.Model/Entities/MediaStream.cs
Original file line number Diff line number Diff line change
Expand Up @@ -656,14 +656,14 @@ public static bool IsTextFormat(string format)
{
string codec = format ?? string.Empty;

// sub = external .sub file

return !codec.Contains("pgs", StringComparison.OrdinalIgnoreCase)
&& !codec.Contains("dvd", StringComparison.OrdinalIgnoreCase)
&& !codec.Contains("dvbsub", StringComparison.OrdinalIgnoreCase)
&& !string.Equals(codec, "sub", StringComparison.OrdinalIgnoreCase)
&& !string.Equals(codec, "sup", StringComparison.OrdinalIgnoreCase)
&& !string.Equals(codec, "dvb_subtitle", StringComparison.OrdinalIgnoreCase);
// microdvd and dvdsub/vobsub share the ".sub" file extension, but it's text-based.

return codec.Contains("microdvd", StringComparison.OrdinalIgnoreCase)
|| (!codec.Contains("pgs", StringComparison.OrdinalIgnoreCase)
&& !codec.Contains("dvdsub", StringComparison.OrdinalIgnoreCase)
&& !codec.Contains("dvbsub", StringComparison.OrdinalIgnoreCase)
&& !string.Equals(codec, "sup", StringComparison.OrdinalIgnoreCase)
&& !string.Equals(codec, "sub", StringComparison.OrdinalIgnoreCase));
}

public bool SupportsSubtitleConversionTo(string toCodec)
Expand Down

0 comments on commit d37c5d8

Please sign in to comment.