Fix batch convert of blu-ray sup file to vobsub - thx John :)

This commit is contained in:
Nikolaj Olsson 2020-10-10 07:16:46 +02:00
parent 7540f414c4
commit db19d09cc5
2 changed files with 15 additions and 2 deletions

View File

@ -2046,7 +2046,9 @@ namespace Nikse.SubtitleEdit.Forms
try try
{ {
var binaryParagraphs = new List<IBinaryParagraph>(); var binaryParagraphs = new List<IBinaryParagraph>();
if (p.FileName != null && p.FileName.EndsWith(".sup", StringComparison.OrdinalIgnoreCase) && FileUtil.IsBluRaySup(p.FileName) && AllowImageToImage()) if (p.FileName != null && !p.Subtitle.Paragraphs.Any(s => !string.IsNullOrEmpty(s.Text)) &&
p.FileName.EndsWith(".sup", StringComparison.OrdinalIgnoreCase) &&
FileUtil.IsBluRaySup(p.FileName) && AllowImageToImage())
{ {
binaryParagraphs = BluRaySupParser.ParseBluRaySup(p.FileName, new StringBuilder()).Cast<IBinaryParagraph>().ToList(); binaryParagraphs = BluRaySupParser.ParseBluRaySup(p.FileName, new StringBuilder()).Cast<IBinaryParagraph>().ToList();
} }

View File

@ -1150,7 +1150,7 @@ namespace Nikse.SubtitleEdit.Logic.CommandLineConvert
bool targetFormatFound = false; bool targetFormatFound = false;
string outputFileName; string outputFileName;
if (binaryParagraphs != null && binaryParagraphs.Count > 0) if (binaryParagraphs != null && binaryParagraphs.Count > 0 && !HasImageTarget(targetFormat))
{ {
using (var vobSubOcr = new VobSubOcr()) using (var vobSubOcr = new VobSubOcr())
{ {
@ -1764,6 +1764,17 @@ namespace Nikse.SubtitleEdit.Logic.CommandLineConvert
} }
} }
private static bool HasImageTarget(string targetFormat)
{
var target = targetFormat.RemoveChar(' ');
return BatchConvert.BluRaySubtitle.RemoveChar(' ').Equals(target, StringComparison.OrdinalIgnoreCase) ||
BatchConvert.VobSubSubtitle.RemoveChar(' ').Equals(target, StringComparison.OrdinalIgnoreCase) ||
BatchConvert.DostImageSubtitle.RemoveChar(' ').Equals(target, StringComparison.OrdinalIgnoreCase) ||
BatchConvert.BdnXmlSubtitle.RemoveChar(' ').Equals(target, StringComparison.OrdinalIgnoreCase) ||
BatchConvert.FcpImageSubtitle.RemoveChar(' ').Equals(target, StringComparison.OrdinalIgnoreCase);
}
internal static Subtitle RunActions(TextEncoding targetEncoding, Subtitle sub, SubtitleFormat format, List<BatchAction> actions, bool autoDetectLanguage) internal static Subtitle RunActions(TextEncoding targetEncoding, Subtitle sub, SubtitleFormat format, List<BatchAction> actions, bool autoDetectLanguage)
{ {
if (actions != null) if (actions != null)