This commit is contained in:
niksedk 2023-03-13 18:44:14 +01:00
parent d5cc4f3bb4
commit f9bfa08d29
11 changed files with 83 additions and 3 deletions

View File

@ -855,6 +855,8 @@ Read more info (web)?</WhisperNotFound>
<SolidColor>Solid color</SolidColor>
<DurationInMinutes>Duration in minutes</DurationInMinutes>
<Background>Background</Background>
<FfmpegParameters>Run FFmpeg with the following parameters:</FfmpegParameters>
<GenerateWithFfmpegParametersPrompt>Generate - prompt FFmpeg parameters</GenerateWithFfmpegParametersPrompt>
</GenerateBlankVideo>
<GenerateVideoWithBurnedInSubs>
<Title>Generate video with burned-in subtitle</Title>
@ -2662,6 +2664,7 @@ Continue?</RestoreDefaultSettingsMsg>
<PreviewPause>(pause)</PreviewPause>
<CustomContinuationStyleNote>Note: The custom continuation style is shared across profiles.</CustomContinuationStyleNote>
<ResetCustomContinuationStyleWarning>This will override the values in the dialog. Are you sure?</ResetCustomContinuationStyleWarning>
<ExportAsHtml>Export as HTML...</ExportAsHtml>
</Settings>
<SettingsMpv>
<DownloadMpv>Download mpv lib</DownloadMpv>

View File

@ -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;
}
}

View File

@ -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);
}
}
}

View File

@ -117,6 +117,9 @@
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<metadata name="contextMenuStripGenerate.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>442, 18</value>
</metadata>
<metadata name="timer1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>

View File

@ -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;
}

View File

@ -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;

View File

@ -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);

View File

@ -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("</html>");
File.WriteAllText(saveFileDialog1.FileName, html.ToString());
UiUtil.OpenFolderFromFileName(saveFileDialog1.FileName);
}
}
}

View File

@ -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

View File

@ -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;

View File

@ -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