From f9bfa08d29275db6013dd55db4108d8cbd46861c Mon Sep 17 00:00:00 2001 From: niksedk Date: Mon, 13 Mar 2023 18:44:14 +0100 Subject: [PATCH] Work on #6725 --- LanguageBaseEnglish.xml | 3 ++ src/ui/Forms/GenerateVideo.Designer.cs | 23 ++++++++++++++- src/ui/Forms/GenerateVideo.cs | 36 ++++++++++++++++++++++- src/ui/Forms/GenerateVideo.resx | 3 ++ src/ui/Forms/GenerateVideoFFmpegPrompt.cs | 2 +- src/ui/Forms/GenerateVideoWithHardSubs.cs | 1 + src/ui/Forms/GenerateVideoWithSoftSubs.cs | 1 + src/ui/Forms/Options/Settings.cs | 2 ++ src/ui/Logic/Language.cs | 3 ++ src/ui/Logic/LanguageDeserializer.cs | 9 ++++++ src/ui/Logic/LanguageStructure.cs | 3 ++ 11 files changed, 83 insertions(+), 3 deletions(-) diff --git a/LanguageBaseEnglish.xml b/LanguageBaseEnglish.xml index 56afdbe07..cd15546e1 100644 --- a/LanguageBaseEnglish.xml +++ b/LanguageBaseEnglish.xml @@ -855,6 +855,8 @@ Read more info (web)? Solid color Duration in minutes Background + Run FFmpeg with the following parameters: + Generate - prompt FFmpeg parameters Generate video with burned-in subtitle @@ -2662,6 +2664,7 @@ Continue? (pause) Note: The custom continuation style is shared across profiles. This will override the values in the dialog. Are you sure? + Export as HTML... Download mpv lib diff --git a/src/ui/Forms/GenerateVideo.Designer.cs b/src/ui/Forms/GenerateVideo.Designer.cs index 0c40c18e1..6e2a835c3 100644 --- a/src/ui/Forms/GenerateVideo.Designer.cs +++ b/src/ui/Forms/GenerateVideo.Designer.cs @@ -33,6 +33,8 @@ namespace Nikse.SubtitleEdit.Forms this.panelColor = new System.Windows.Forms.Panel(); this.buttonColor = new System.Windows.Forms.Button(); this.buttonGenerate = new System.Windows.Forms.Button(); + this.contextMenuStripGenerate = new System.Windows.Forms.ContextMenuStrip(this.components); + this.promptParameterBeforeGenerateToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.buttonCancel = new System.Windows.Forms.Button(); this.progressBar1 = new System.Windows.Forms.ProgressBar(); this.labelDuration = new System.Windows.Forms.Label(); @@ -71,6 +73,7 @@ namespace Nikse.SubtitleEdit.Forms this.buttonVideoChooseStandardRes = new System.Windows.Forms.Button(); this.buttonChooseDuration = new System.Windows.Forms.Button(); this.checkBoxAddTimeCode = new System.Windows.Forms.CheckBox(); + this.contextMenuStripGenerate.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.numericUpDownWidth)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.numericUpDownHeight)).BeginInit(); this.groupBoxBackground.SuspendLayout(); @@ -100,6 +103,7 @@ namespace Nikse.SubtitleEdit.Forms // buttonGenerate // this.buttonGenerate.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.buttonGenerate.ContextMenuStrip = this.contextMenuStripGenerate; this.buttonGenerate.ImeMode = System.Windows.Forms.ImeMode.NoControl; this.buttonGenerate.Location = new System.Drawing.Point(549, 249); this.buttonGenerate.Name = "buttonGenerate"; @@ -107,7 +111,21 @@ namespace Nikse.SubtitleEdit.Forms this.buttonGenerate.TabIndex = 20; this.buttonGenerate.Text = "Generate"; this.buttonGenerate.UseVisualStyleBackColor = true; - this.buttonGenerate.Click += new System.EventHandler(this.buttonOK_Click); + this.buttonGenerate.Click += new System.EventHandler(this.buttonGenerate_Click); + // + // contextMenuStripGenerate + // + this.contextMenuStripGenerate.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.promptParameterBeforeGenerateToolStripMenuItem}); + this.contextMenuStripGenerate.Name = "contextMenuStripGenerate"; + this.contextMenuStripGenerate.Size = new System.Drawing.Size(290, 48); + // + // promptParameterBeforeGenerateToolStripMenuItem + // + this.promptParameterBeforeGenerateToolStripMenuItem.Name = "promptParameterBeforeGenerateToolStripMenuItem"; + this.promptParameterBeforeGenerateToolStripMenuItem.Size = new System.Drawing.Size(289, 22); + this.promptParameterBeforeGenerateToolStripMenuItem.Text = "Prompt FFmpeg parameter and generate"; + this.promptParameterBeforeGenerateToolStripMenuItem.Click += new System.EventHandler(this.promptParameterBeforeGenerateToolStripMenuItem_Click); // // buttonCancel // @@ -539,6 +557,7 @@ namespace Nikse.SubtitleEdit.Forms this.Text = "GenerateVideo"; this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.GenerateVideo_FormClosing); this.Shown += new System.EventHandler(this.GenerateVideo_Shown); + this.contextMenuStripGenerate.ResumeLayout(false); ((System.ComponentModel.ISupportInitialize)(this.numericUpDownWidth)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.numericUpDownHeight)).EndInit(); this.groupBoxBackground.ResumeLayout(false); @@ -592,5 +611,7 @@ namespace Nikse.SubtitleEdit.Forms private System.Windows.Forms.Button buttonChooseDuration; private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemResBrowse; private System.Windows.Forms.CheckBox checkBoxAddTimeCode; + private System.Windows.Forms.ContextMenuStrip contextMenuStripGenerate; + private System.Windows.Forms.ToolStripMenuItem promptParameterBeforeGenerateToolStripMenuItem; } } \ No newline at end of file diff --git a/src/ui/Forms/GenerateVideo.cs b/src/ui/Forms/GenerateVideo.cs index 519be60f6..3e3cf63a3 100644 --- a/src/ui/Forms/GenerateVideo.cs +++ b/src/ui/Forms/GenerateVideo.cs @@ -21,6 +21,7 @@ namespace Nikse.SubtitleEdit.Forms private long _totalFrames; private static readonly Regex FrameFinderRegex = new Regex(@"[Ff]rame=\s*\d+", RegexOptions.Compiled); private Bitmap _backgroundImage; + private bool _promptFFmpegParameters; public GenerateVideo(Subtitle subtitle, VideoInfo videoInfo) { @@ -136,7 +137,7 @@ namespace Nikse.SubtitleEdit.Forms } } - private void buttonOK_Click(object sender, EventArgs e) + private void buttonGenerate_Click(object sender, EventArgs e) { EnableDisableControls(false); @@ -182,6 +183,12 @@ namespace Nikse.SubtitleEdit.Forms checkBoxAddTimeCode.Checked, addTimeColor); + if (!CheckForPromptParameters(process, Text)) + { + _abort = true; + return; + } + process.Start(); process.BeginOutputReadLine(); process.BeginErrorReadLine(); @@ -212,6 +219,26 @@ namespace Nikse.SubtitleEdit.Forms DialogResult = _abort ? DialogResult.Cancel : DialogResult.OK; } + private bool CheckForPromptParameters(Process process, string title) + { + if (!_promptFFmpegParameters) + { + return true; + } + + using (var form = new GenerateVideoFFmpegPrompt(title, process.StartInfo.Arguments)) + { + if (form.ShowDialog(this) != DialogResult.OK) + { + return false; + } + + process.StartInfo.Arguments = form.Parameters; + } + + return true; + } + private void EnableDisableControls(bool enable) { buttonGenerate.Enabled = enable; @@ -374,5 +401,12 @@ namespace Nikse.SubtitleEdit.Forms { buttonGenerate.Show(); } + + private void promptParameterBeforeGenerateToolStripMenuItem_Click(object sender, EventArgs e) + { + _promptFFmpegParameters = true; + buttonGenerate_Click(null, null); + + } } } diff --git a/src/ui/Forms/GenerateVideo.resx b/src/ui/Forms/GenerateVideo.resx index 6a4839494..272cac292 100644 --- a/src/ui/Forms/GenerateVideo.resx +++ b/src/ui/Forms/GenerateVideo.resx @@ -117,6 +117,9 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + 442, 18 + 17, 17 diff --git a/src/ui/Forms/GenerateVideoFFmpegPrompt.cs b/src/ui/Forms/GenerateVideoFFmpegPrompt.cs index 1bea2f8bf..5d8e7347b 100644 --- a/src/ui/Forms/GenerateVideoFFmpegPrompt.cs +++ b/src/ui/Forms/GenerateVideoFFmpegPrompt.cs @@ -17,7 +17,7 @@ namespace Nikse.SubtitleEdit.Forms Text = title; textBox1.Text = parameters.Trim(); - //TODO: labelFFmpeg.Text = LanguageSettings.Current.GenerateBlankVideo.DurationInMinutes; + labelFFmpeg.Text = LanguageSettings.Current.GenerateBlankVideo.FfmpegParameters; buttonOK.Text = LanguageSettings.Current.Watermark.Generate; buttonCancel.Text = LanguageSettings.Current.General.Cancel; } diff --git a/src/ui/Forms/GenerateVideoWithHardSubs.cs b/src/ui/Forms/GenerateVideoWithHardSubs.cs index 71294b375..05e8682a3 100644 --- a/src/ui/Forms/GenerateVideoWithHardSubs.cs +++ b/src/ui/Forms/GenerateVideoWithHardSubs.cs @@ -82,6 +82,7 @@ namespace Nikse.SubtitleEdit.Forms groupBoxSettings.Text = LanguageSettings.Current.Settings.Title; groupBoxVideo.Text = LanguageSettings.Current.Main.Menu.Video.Title; groupBoxAudio.Text = LanguageSettings.Current.GenerateVideoWithBurnedInSubs.Audio; + promptParameterBeforeGenerateToolStripMenuItem.Text = LanguageSettings.Current.GenerateBlankVideo.GenerateWithFfmpegParametersPrompt; comboBoxVideoEncoding.Text = Configuration.Settings.Tools.GenVideoEncoding; comboBoxCrf.Text = Configuration.Settings.Tools.GenVideoCrf; diff --git a/src/ui/Forms/GenerateVideoWithSoftSubs.cs b/src/ui/Forms/GenerateVideoWithSoftSubs.cs index ff2c1a388..22d4c055d 100644 --- a/src/ui/Forms/GenerateVideoWithSoftSubs.cs +++ b/src/ui/Forms/GenerateVideoWithSoftSubs.cs @@ -56,6 +56,7 @@ namespace Nikse.SubtitleEdit.Forms columnHeader5FileName.Text = LanguageSettings.Current.JoinSubtitles.FileName; buttonGenerate.Text = LanguageSettings.Current.Watermark.Generate; buttonCancel.Text = LanguageSettings.Current.General.Cancel; + promptParameterBeforeGenerateToolStripMenuItem.Text = LanguageSettings.Current.GenerateBlankVideo.GenerateWithFfmpegParametersPrompt; labelSubtitles.Text = string.Format(LanguageSettings.Current.GenerateVideoWithEmbeddedSubs.SubtitlesX, 0); LoadVideo(inputVideoFileName); diff --git a/src/ui/Forms/Options/Settings.cs b/src/ui/Forms/Options/Settings.cs index 7c0d24036..dd9deb8c8 100644 --- a/src/ui/Forms/Options/Settings.cs +++ b/src/ui/Forms/Options/Settings.cs @@ -1024,6 +1024,7 @@ namespace Nikse.SubtitleEdit.Forms.Options toolStripMenuItemShortcutsCollapse.Text = LanguageSettings.Current.General.Collapse; importShortcutsToolStripMenuItem.Text = LanguageSettings.Current.MultipleReplace.Import; exportShortcutsToolStripMenuItem.Text = LanguageSettings.Current.MultipleReplace.Export; + exportAsHtmlToolStripMenuItem.Text = LanguageSettings.Current.Settings.ExportAsHtml; labelShortcutsSearch.Text = LanguageSettings.Current.General.Search; buttonShortcutsClear.Text = LanguageSettings.Current.DvdSubRip.Clear; textBoxShortcutSearch.Left = labelShortcutsSearch.Left + labelShortcutsSearch.Width + 5; @@ -3474,6 +3475,7 @@ namespace Nikse.SubtitleEdit.Forms.Options html.AppendLine(""); File.WriteAllText(saveFileDialog1.FileName, html.ToString()); + UiUtil.OpenFolderFromFileName(saveFileDialog1.FileName); } } } diff --git a/src/ui/Logic/Language.cs b/src/ui/Logic/Language.cs index 2a46fe838..1f037e88f 100644 --- a/src/ui/Logic/Language.cs +++ b/src/ui/Logic/Language.cs @@ -1081,6 +1081,8 @@ namespace Nikse.SubtitleEdit.Logic DurationInMinutes = "Duration in minutes", SolidColor = "Solid color", Background = "Background", + FfmpegParameters = "Run FFmpeg with the following parameters:", + GenerateWithFfmpegParametersPrompt = "Generate - prompt FFmpeg parameters", }; GenerateVideoWithBurnedInSubs = new LanguageStructure.GenerateVideoWithBurnedInSubs @@ -2997,6 +2999,7 @@ can edit in same subtitle file (collaboration)", PreviewPause = "(pause)", CustomContinuationStyleNote = "Note: The custom continuation style is shared across profiles.", ResetCustomContinuationStyleWarning = "This will override the values in the dialog. Are you sure?", + ExportAsHtml = "Export as HTML...", }; SettingsMpv = new LanguageStructure.SettingsMpv diff --git a/src/ui/Logic/LanguageDeserializer.cs b/src/ui/Logic/LanguageDeserializer.cs index 6fad18de5..3d0fd4c4a 100644 --- a/src/ui/Logic/LanguageDeserializer.cs +++ b/src/ui/Logic/LanguageDeserializer.cs @@ -2266,6 +2266,12 @@ namespace Nikse.SubtitleEdit.Logic case "GenerateBlankVideo/Background": language.GenerateBlankVideo.Background = reader.Value; break; + case "GenerateBlankVideo/FfmpegParameters": + language.GenerateBlankVideo.FfmpegParameters = reader.Value; + break; + case "GenerateBlankVideo/GenerateWithFfmpegParametersPrompt": + language.GenerateBlankVideo.GenerateWithFfmpegParametersPrompt = reader.Value; + break; case "GenerateVideoWithBurnedInSubs/Title": language.GenerateVideoWithBurnedInSubs.Title = reader.Value; break; @@ -7315,6 +7321,9 @@ namespace Nikse.SubtitleEdit.Logic case "Settings/ResetCustomContinuationStyleWarning": language.Settings.ResetCustomContinuationStyleWarning = reader.Value; break; + case "Settings/ExportAsHtml": + language.Settings.ExportAsHtml = reader.Value; + break; case "SettingsMpv/DownloadMpv": language.SettingsMpv.DownloadMpv = reader.Value; break; diff --git a/src/ui/Logic/LanguageStructure.cs b/src/ui/Logic/LanguageStructure.cs index ea34a8106..8c92e1319 100644 --- a/src/ui/Logic/LanguageStructure.cs +++ b/src/ui/Logic/LanguageStructure.cs @@ -940,6 +940,8 @@ namespace Nikse.SubtitleEdit.Logic public string SolidColor { get; set; } public string DurationInMinutes { get; set; } public string Background { get; set; } + public string FfmpegParameters { get; set; } + public string GenerateWithFfmpegParametersPrompt { get; set; } } public class GenerateVideoWithBurnedInSubs @@ -2846,6 +2848,7 @@ namespace Nikse.SubtitleEdit.Logic public string PreviewPause { get; set; } public string CustomContinuationStyleNote { get; set; } public string ResetCustomContinuationStyleWarning { get; set; } + public string ExportAsHtml { get; set; } } public class SettingsMpv