From 264da9188d23ff61f2d9ce206924a3e48a2178dc Mon Sep 17 00:00:00 2001 From: Nikolaj Olsson Date: Fri, 19 Apr 2024 22:35:23 +0200 Subject: [PATCH] Work on #8210 --- Changelog.txt | 3 +- .../GenerateVideoWithHardSubs.Designer.cs | 51 +++++++------- src/ui/Forms/GenerateVideoWithHardSubs.cs | 69 +++++++++++++++---- 3 files changed, 82 insertions(+), 41 deletions(-) diff --git a/Changelog.txt b/Changelog.txt index fbfd3ed2f..1cbe3fdee 100644 --- a/Changelog.txt +++ b/Changelog.txt @@ -1,8 +1,9 @@ Subtitle Edit Changelog -4.0.6 (xth March 2024) BETA +4.0.6 (xth May 2024) BETA * NEW: * Add "Text To Speech" - thx darnn + * Add burn-in batch mode - thx Leon * IMPROVED: * Update Portuguese translation - thx hugok79 * Update Bulgarian translation - thx Калин diff --git a/src/ui/Forms/GenerateVideoWithHardSubs.Designer.cs b/src/ui/Forms/GenerateVideoWithHardSubs.Designer.cs index f462f8e4f..26b69b436 100644 --- a/src/ui/Forms/GenerateVideoWithHardSubs.Designer.cs +++ b/src/ui/Forms/GenerateVideoWithHardSubs.Designer.cs @@ -54,6 +54,8 @@ namespace Nikse.SubtitleEdit.Forms this.groupBoxVideo = new System.Windows.Forms.GroupBox(); this.buttonVideoChooseStandardRes = new System.Windows.Forms.Button(); this.groupBoxAudio = new System.Windows.Forms.GroupBox(); + this.listViewAudioTracks = new System.Windows.Forms.ListView(); + this.columnHeaderAudioTrack = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); this.checkBoxMakeStereo = new System.Windows.Forms.CheckBox(); this.checkBoxTargetFileSize = new System.Windows.Forms.CheckBox(); this.listViewBatch = new System.Windows.Forms.ListView(); @@ -85,8 +87,6 @@ namespace Nikse.SubtitleEdit.Forms this.x352ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.x272ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.buttonMode = new System.Windows.Forms.Button(); - this.listViewAudioTracks = new System.Windows.Forms.ListView(); - this.columnHeaderAudioTrack = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); this.labelPreviewPleaseWait = new Nikse.SubtitleEdit.Controls.NikseLabel(); this.videoPlayerContainer1 = new Nikse.SubtitleEdit.Controls.VideoPlayerContainer(); this.numericUpDownCutToSeconds = new Nikse.SubtitleEdit.Controls.NikseUpDown(); @@ -232,7 +232,7 @@ namespace Nikse.SubtitleEdit.Forms // // buttonClear // - this.buttonClear.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); + this.buttonClear.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); this.buttonClear.Location = new System.Drawing.Point(165, 513); this.buttonClear.Name = "buttonClear"; this.buttonClear.Size = new System.Drawing.Size(74, 23); @@ -252,7 +252,7 @@ namespace Nikse.SubtitleEdit.Forms // // buttonRemoveFile // - this.buttonRemoveFile.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); + this.buttonRemoveFile.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); this.buttonRemoveFile.Location = new System.Drawing.Point(85, 513); this.buttonRemoveFile.Name = "buttonRemoveFile"; this.buttonRemoveFile.Size = new System.Drawing.Size(74, 23); @@ -273,7 +273,7 @@ namespace Nikse.SubtitleEdit.Forms // // buttonAddFile // - this.buttonAddFile.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); + this.buttonAddFile.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); this.buttonAddFile.Location = new System.Drawing.Point(6, 513); this.buttonAddFile.Name = "buttonAddFile"; this.buttonAddFile.Size = new System.Drawing.Size(73, 23); @@ -438,6 +438,26 @@ namespace Nikse.SubtitleEdit.Forms this.groupBoxAudio.TabStop = false; this.groupBoxAudio.Text = "Audio"; // + // listViewAudioTracks + // + this.listViewAudioTracks.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.listViewAudioTracks.CheckBoxes = true; + this.listViewAudioTracks.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] { + this.columnHeaderAudioTrack}); + this.listViewAudioTracks.HideSelection = false; + this.listViewAudioTracks.Location = new System.Drawing.Point(229, 29); + this.listViewAudioTracks.Name = "listViewAudioTracks"; + this.listViewAudioTracks.Size = new System.Drawing.Size(190, 122); + this.listViewAudioTracks.TabIndex = 45; + this.listViewAudioTracks.UseCompatibleStateImageBehavior = false; + this.listViewAudioTracks.View = System.Windows.Forms.View.Details; + // + // columnHeaderAudioTrack + // + this.columnHeaderAudioTrack.Text = "Audio tracks"; + this.columnHeaderAudioTrack.Width = 160; + // // checkBoxMakeStereo // this.checkBoxMakeStereo.AutoSize = true; @@ -527,6 +547,7 @@ namespace Nikse.SubtitleEdit.Forms this.pickSubtitleFileToolStripMenuItem.Name = "pickSubtitleFileToolStripMenuItem"; this.pickSubtitleFileToolStripMenuItem.Size = new System.Drawing.Size(166, 22); this.pickSubtitleFileToolStripMenuItem.Text = "Pick subtitle file..."; + this.pickSubtitleFileToolStripMenuItem.Click += new System.EventHandler(this.pickSubtitleFileToolStripMenuItem_Click); // // toolStripSeparator1 // @@ -700,26 +721,6 @@ namespace Nikse.SubtitleEdit.Forms this.buttonMode.UseVisualStyleBackColor = true; this.buttonMode.Click += new System.EventHandler(this.buttonMode_Click); // - // listViewAudioTracks - // - this.listViewAudioTracks.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.listViewAudioTracks.CheckBoxes = true; - this.listViewAudioTracks.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] { - this.columnHeaderAudioTrack}); - this.listViewAudioTracks.HideSelection = false; - this.listViewAudioTracks.Location = new System.Drawing.Point(229, 29); - this.listViewAudioTracks.Name = "listViewAudioTracks"; - this.listViewAudioTracks.Size = new System.Drawing.Size(190, 122); - this.listViewAudioTracks.TabIndex = 45; - this.listViewAudioTracks.UseCompatibleStateImageBehavior = false; - this.listViewAudioTracks.View = System.Windows.Forms.View.Details; - // - // columnHeaderAudioTrack - // - this.columnHeaderAudioTrack.Text = "Audio tracks"; - this.columnHeaderAudioTrack.Width = 160; - // // labelPreviewPleaseWait // this.labelPreviewPleaseWait.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); diff --git a/src/ui/Forms/GenerateVideoWithHardSubs.cs b/src/ui/Forms/GenerateVideoWithHardSubs.cs index 1f4acce1f..0c028a2e6 100644 --- a/src/ui/Forms/GenerateVideoWithHardSubs.cs +++ b/src/ui/Forms/GenerateVideoWithHardSubs.cs @@ -38,6 +38,7 @@ namespace Nikse.SubtitleEdit.Forms public string VideoFileName { get; private set; } public long MillisecondsEncoding { get; private set; } private PreviewVideo _previewVideo; + private readonly bool _initialFontOn; public bool BatchMode { get; set; } public string BatchInfo { get; set; } private readonly List _batchVideoAndSubList; @@ -176,6 +177,12 @@ namespace Nikse.SubtitleEdit.Forms numericUpDownCutToMinutes.Left = numericUpDownCutToHours.Right + 1; numericUpDownCutToSeconds.Left = numericUpDownCutToMinutes.Right + 1; + if (string.IsNullOrEmpty(inputVideoFileName) || _videoInfo == null || _videoInfo.Width == 0 || _videoInfo.Height == 0) + { + buttonMode_Click(null, null); + buttonMode.Visible = false; + } + _isAssa = !fontSize.HasValue; if (fontSize.HasValue && !_noSubtitles) { @@ -194,21 +201,12 @@ namespace Nikse.SubtitleEdit.Forms checkBoxRightToLeft.Checked = Configuration.Settings.General.RightToLeftMode && LanguageAutoDetect.CouldBeRightToLeftLanguage(_assaSubtitle); + _initialFontOn = true; } else { - numericUpDownFontSize.Enabled = false; - labelFontSize.Enabled = false; - labelSubtitleFont.Enabled = false; - comboBoxSubtitleFont.Enabled = false; - checkBoxRightToLeft.Left = checkBoxTargetFileSize.Left; - checkBoxAlignRight.Enabled = false; - checkBoxBox.Enabled = false; - labelInfo.Text = LanguageSettings.Current.GenerateVideoWithBurnedInSubs.InfoAssaOn; - buttonForeColor.Enabled = false; - buttonOutlineColor.Enabled = false; - panelOutlineColor.Enabled = false; - panelForeColor.Enabled = false; + _initialFontOn = false; + FontEnableOrDisable(false); } var initialFont = Configuration.Settings.Tools.GenVideoFontName; @@ -216,6 +214,7 @@ namespace Nikse.SubtitleEdit.Forms { initialFont = Configuration.Settings.Tools.ExportBluRayFontName; } + labelInfo.Text = LanguageSettings.Current.GenerateVideoWithBurnedInSubs.InfoAssaOn; if (string.IsNullOrEmpty(initialFont)) { initialFont = UiUtil.GetDefaultFont().Name; @@ -336,11 +335,30 @@ namespace Nikse.SubtitleEdit.Forms listViewAudioTracks.Visible = false; } + FontEnableOrDisable(BatchMode || _initialFontOn); + } - if (string.IsNullOrEmpty(inputVideoFileName) || _videoInfo == null || _videoInfo.Width == 0 || _videoInfo.Height == 0) + private void FontEnableOrDisable(bool enabled) + { + numericUpDownFontSize.Enabled = enabled; + labelFontSize.Enabled = enabled; + labelSubtitleFont.Enabled = enabled; + comboBoxSubtitleFont.Enabled = enabled; + checkBoxRightToLeft.Left = checkBoxTargetFileSize.Left; + checkBoxAlignRight.Enabled = enabled; + checkBoxBox.Enabled = enabled; + buttonForeColor.Enabled = enabled; + buttonOutlineColor.Enabled = enabled; + panelOutlineColor.Enabled = enabled; + panelForeColor.Enabled = enabled; + + if (!BatchMode) { - buttonMode_Click(null, null); - buttonMode.Visible = false; + labelInfo.Text = LanguageSettings.Current.GenerateVideoWithBurnedInSubs.InfoAssaOn; + } + else + { + labelInfo.Text = string.Empty; } } @@ -1935,6 +1953,8 @@ namespace Nikse.SubtitleEdit.Forms buttonMode.Text = BatchMode ? LanguageSettings.Current.AudioToText.BatchMode : LanguageSettings.Current.Split.Basic; + + FontEnableOrDisable(BatchMode || _initialFontOn); } private void addFilesToolStripMenuItem_Click(object sender, EventArgs e) @@ -2107,5 +2127,24 @@ namespace Nikse.SubtitleEdit.Forms { clearToolStripMenuItem_Click(null, null); } + + private void pickSubtitleFileToolStripMenuItem_Click(object sender, EventArgs e) + { + using (var openFileDialog1 = new OpenFileDialog()) + { + openFileDialog1.Title = LanguageSettings.Current.General.OpenSubtitle; + openFileDialog1.FileName = string.Empty; + openFileDialog1.Filter = UiUtil.SubtitleExtensionFilter.Value; + openFileDialog1.Multiselect = false; + if (openFileDialog1.ShowDialog(this) != DialogResult.OK) + { + return; + } + + var idx = listViewBatch.SelectedIndices[0]; + _batchVideoAndSubList[idx].SubtitleFileName = openFileDialog1.FileName; + listViewBatch.Items[idx].SubItems[2].Text = Path.GetFileName(openFileDialog1.FileName); + } + } } }