Fix MicroDVD being recognized as DVDSUB subtitles (#12149)

This commit is contained in:
Nyanmisaka 2024-06-21 23:07:25 +08:00 committed by GitHub
parent 85078d8f10
commit 6010bc01c3
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 18 additions and 14 deletions

View File

@ -1208,8 +1208,8 @@ namespace MediaBrowser.Controller.MediaEncoding
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))

View File

@ -624,15 +624,19 @@ namespace MediaBrowser.MediaEncoding.Probing
{
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;

View File

@ -656,14 +656,14 @@ namespace MediaBrowser.Model.Entities
{
string codec = format ?? string.Empty;
// sub = external .sub file
// microdvd and dvdsub/vobsub share the ".sub" file extension, but it's text-based.
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);
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)