Fix crash in TS convert - thx MounaLafi :)

Work on #8470
This commit is contained in:
Nikolaj Olsson 2024-06-04 20:03:20 +02:00
parent ebc789afbb
commit 50a9cf5b98
2 changed files with 15 additions and 2 deletions

View File

@ -474,6 +474,11 @@ namespace Nikse.SubtitleEdit.Forms
internal MakeBitmapParameter MakeMakeBitmapParameter(int index, int screenWidth, int screenHeight)
{
var p = _subtitle.GetParagraphOrDefault(index);
if (p == null)
{
p = new Paragraph();
}
var parameter = new MakeBitmapParameter
{
Type = _exportType,
@ -510,6 +515,7 @@ namespace Nikse.SubtitleEdit.Forms
FullFrame = checkBoxFullFrameImage.Checked,
FullFrameBackgroundColor = panelFullFrameBackground.BackColor,
};
if (index < _subtitle.Paragraphs.Count)
{
parameter.P = _subtitle.Paragraphs[index];
@ -571,6 +577,7 @@ namespace Nikse.SubtitleEdit.Forms
{
parameter.P = null;
}
return parameter;
}

View File

@ -21,13 +21,19 @@ namespace Nikse.SubtitleEdit.Logic.CommandLineConvert
using (var form = new ExportPngXml())
{
form.Initialize(new Subtitle(), new SubRip(), BatchConvert.BluRaySubtitle, fileName, null, fileName);
var sub = tsParser.GetDvbSubtitles(pid);
var tempSubtitle = new Subtitle();
foreach (var x in sub)
{
tempSubtitle.Paragraphs.Add(new Paragraph(string.Empty, x.StartMilliseconds, x.EndMilliseconds));
}
form.Initialize(tempSubtitle, new SubRip(), BatchConvert.BluRaySubtitle, fileName, null, fileName);
var language = GetFileNameEnding(programMapTableParser, pid);
var outputFileName = CommandLineConverter.FormatOutputFileNameForBatchConvert(Utilities.GetPathAndFileNameWithoutExtension(fileName) + language + Path.GetExtension(fileName), ".sup", outputFolder, overwrite);
stdOutWriter?.Write($"{count}: {Path.GetFileName(fileName)} -> PID {pid} to {outputFileName}...");
var sub = tsParser.GetDvbSubtitles(pid);
progressCallback?.Invoke($"Save PID {pid}");
var subtitleScreenSize = GetSubtitleScreenSize(sub, overrideScreenSize, resolution);
using (var binarySubtitleFile = new FileStream(outputFileName, FileMode.Create))