From 913308c3909dc1f749abab34d459222e4f4a7549 Mon Sep 17 00:00:00 2001 From: niksedk Date: Fri, 15 Jul 2022 16:38:54 +0200 Subject: [PATCH] Fix crash when gen blank video with no sub --- src/ui/Forms/GenerateVideo.cs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/ui/Forms/GenerateVideo.cs b/src/ui/Forms/GenerateVideo.cs index c684e5143..a4ec0266e 100644 --- a/src/ui/Forms/GenerateVideo.cs +++ b/src/ui/Forms/GenerateVideo.cs @@ -28,7 +28,13 @@ namespace Nikse.SubtitleEdit.Forms UiUtil.FixFonts(this); numericUpDownDurationMinutes.Value = Configuration.Settings.Tools.BlankVideoMinutes; - var maxTimeP = subtitle?.Paragraphs.Where(p => !p.EndTime.IsMaxTime).Max(p => p.EndTime.TotalMilliseconds); + + double? maxTimeP = null; + if (subtitle?.Paragraphs != null && subtitle.Paragraphs.Count > 0) + { + maxTimeP = subtitle?.Paragraphs.Where(p => !p.EndTime.IsMaxTime).Max(p => p.EndTime.TotalMilliseconds); + } + if (maxTimeP.HasValue && maxTimeP.Value / 1000 > 120) { var minutes = (int)maxTimeP.Value / 1000 / 60 + 1;