mirror of
https://github.com/SubtitleEdit/subtitleedit.git
synced 2024-10-26 23:12:38 +02:00
Add ffmpeg scene change thresshold to UI
This commit is contained in:
parent
179d1333d4
commit
9d170c0dfa
@ -721,6 +721,8 @@ Note: Do check free disk space.</WaveFileMalformed>
|
||||
<Seconds>Seconds</Seconds>
|
||||
<Milliseconds>Milliseconds</Milliseconds>
|
||||
<GetSceneChangesWithFfmpeg>Generate scene changes with FFmpeg</GetSceneChangesWithFfmpeg>
|
||||
<Sensitivity>Sensitivity</Sensitivity>
|
||||
<SensitivityDescription>Lower value gives more scene changes</SensitivityDescription>
|
||||
</ImportSceneChanges>
|
||||
<ImportText>
|
||||
<Title>Import plain text</Title>
|
||||
|
@ -927,7 +927,9 @@ namespace Nikse.SubtitleEdit.Core
|
||||
Frames = "Frames",
|
||||
Seconds = "Seconds",
|
||||
Milliseconds = "Milliseconds",
|
||||
GetSceneChangesWithFfmpeg = "Generate scene changes with FFmpeg"
|
||||
GetSceneChangesWithFfmpeg = "Generate scene changes with FFmpeg",
|
||||
Sensitivity = "Sensitivity",
|
||||
SensitivityDescription = "Lower value gives more scene changes"
|
||||
};
|
||||
|
||||
ImportText = new LanguageStructure.ImportText
|
||||
|
@ -1888,6 +1888,12 @@ namespace Nikse.SubtitleEdit.Core
|
||||
case "ImportSceneChanges/GetSceneChangesWithFfmpeg":
|
||||
language.ImportSceneChanges.GetSceneChangesWithFfmpeg = reader.Value;
|
||||
break;
|
||||
case "ImportSceneChanges/Sensitivity":
|
||||
language.ImportSceneChanges.Sensitivity = reader.Value;
|
||||
break;
|
||||
case "ImportSceneChanges/SensitivityDescription":
|
||||
language.ImportSceneChanges.SensitivityDescription = reader.Value;
|
||||
break;
|
||||
case "ImportText/Title":
|
||||
language.ImportText.Title = reader.Value;
|
||||
break;
|
||||
|
@ -801,6 +801,8 @@
|
||||
public string Seconds { get; set; }
|
||||
public string Milliseconds { get; set; }
|
||||
public string GetSceneChangesWithFfmpeg { get; set; }
|
||||
public string Sensitivity { get; set; }
|
||||
public string SensitivityDescription { get; set; }
|
||||
}
|
||||
|
||||
public class ImportText
|
||||
|
64
src/Forms/ImportSceneChanges.Designer.cs
generated
64
src/Forms/ImportSceneChanges.Designer.cs
generated
@ -39,6 +39,9 @@
|
||||
this.radioButtonHHMMSSMS = new System.Windows.Forms.RadioButton();
|
||||
this.buttonOpenText = new System.Windows.Forms.Button();
|
||||
this.groupBoxGenerateSceneChanges = new System.Windows.Forms.GroupBox();
|
||||
this.labelThressholdDescription = new System.Windows.Forms.Label();
|
||||
this.numericUpDownThreshold = new System.Windows.Forms.NumericUpDown();
|
||||
this.labelFfmpegThreshold = new System.Windows.Forms.Label();
|
||||
this.buttonDownloadFfmpeg = new System.Windows.Forms.Button();
|
||||
this.buttonImportWithFfmpeg = new System.Windows.Forms.Button();
|
||||
this.textBoxGenerate = new System.Windows.Forms.TextBox();
|
||||
@ -47,6 +50,7 @@
|
||||
this.groupBoxImportText.SuspendLayout();
|
||||
this.groupBoxTimeCodes.SuspendLayout();
|
||||
this.groupBoxGenerateSceneChanges.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)(this.numericUpDownThreshold)).BeginInit();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// buttonCancel
|
||||
@ -174,6 +178,9 @@
|
||||
this.groupBoxGenerateSceneChanges.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
|
||||
| System.Windows.Forms.AnchorStyles.Left)
|
||||
| System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.groupBoxGenerateSceneChanges.Controls.Add(this.labelThressholdDescription);
|
||||
this.groupBoxGenerateSceneChanges.Controls.Add(this.numericUpDownThreshold);
|
||||
this.groupBoxGenerateSceneChanges.Controls.Add(this.labelFfmpegThreshold);
|
||||
this.groupBoxGenerateSceneChanges.Controls.Add(this.buttonDownloadFfmpeg);
|
||||
this.groupBoxGenerateSceneChanges.Controls.Add(this.buttonImportWithFfmpeg);
|
||||
this.groupBoxGenerateSceneChanges.Controls.Add(this.textBoxGenerate);
|
||||
@ -184,6 +191,53 @@
|
||||
this.groupBoxGenerateSceneChanges.TabStop = false;
|
||||
this.groupBoxGenerateSceneChanges.Text = "Generate scene changes";
|
||||
//
|
||||
// labelThressholdDescription
|
||||
//
|
||||
this.labelThressholdDescription.AutoSize = true;
|
||||
this.labelThressholdDescription.ForeColor = System.Drawing.SystemColors.ControlDarkDark;
|
||||
this.labelThressholdDescription.Location = new System.Drawing.Point(115, 384);
|
||||
this.labelThressholdDescription.Name = "labelThressholdDescription";
|
||||
this.labelThressholdDescription.Size = new System.Drawing.Size(195, 13);
|
||||
this.labelThressholdDescription.TabIndex = 5;
|
||||
this.labelThressholdDescription.Text = "Lower value gives more scene changes";
|
||||
//
|
||||
// numericUpDownThreshold
|
||||
//
|
||||
this.numericUpDownThreshold.DecimalPlaces = 1;
|
||||
this.numericUpDownThreshold.Increment = new decimal(new int[] {
|
||||
1,
|
||||
0,
|
||||
0,
|
||||
65536});
|
||||
this.numericUpDownThreshold.Location = new System.Drawing.Point(66, 382);
|
||||
this.numericUpDownThreshold.Maximum = new decimal(new int[] {
|
||||
9,
|
||||
0,
|
||||
0,
|
||||
65536});
|
||||
this.numericUpDownThreshold.Minimum = new decimal(new int[] {
|
||||
1,
|
||||
0,
|
||||
0,
|
||||
65536});
|
||||
this.numericUpDownThreshold.Name = "numericUpDownThreshold";
|
||||
this.numericUpDownThreshold.Size = new System.Drawing.Size(43, 20);
|
||||
this.numericUpDownThreshold.TabIndex = 4;
|
||||
this.numericUpDownThreshold.Value = new decimal(new int[] {
|
||||
4,
|
||||
0,
|
||||
0,
|
||||
65536});
|
||||
//
|
||||
// labelFfmpegThreshold
|
||||
//
|
||||
this.labelFfmpegThreshold.AutoSize = true;
|
||||
this.labelFfmpegThreshold.Location = new System.Drawing.Point(6, 384);
|
||||
this.labelFfmpegThreshold.Name = "labelFfmpegThreshold";
|
||||
this.labelFfmpegThreshold.Size = new System.Drawing.Size(54, 13);
|
||||
this.labelFfmpegThreshold.TabIndex = 3;
|
||||
this.labelFfmpegThreshold.Text = "Sensitivity";
|
||||
//
|
||||
// buttonDownloadFfmpeg
|
||||
//
|
||||
this.buttonDownloadFfmpeg.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
|
||||
@ -199,7 +253,7 @@
|
||||
//
|
||||
this.buttonImportWithFfmpeg.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)
|
||||
| System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.buttonImportWithFfmpeg.Location = new System.Drawing.Point(6, 384);
|
||||
this.buttonImportWithFfmpeg.Location = new System.Drawing.Point(6, 353);
|
||||
this.buttonImportWithFfmpeg.Name = "buttonImportWithFfmpeg";
|
||||
this.buttonImportWithFfmpeg.Size = new System.Drawing.Size(337, 23);
|
||||
this.buttonImportWithFfmpeg.TabIndex = 2;
|
||||
@ -207,7 +261,7 @@
|
||||
this.buttonImportWithFfmpeg.UseVisualStyleBackColor = true;
|
||||
this.buttonImportWithFfmpeg.Click += new System.EventHandler(this.buttonImportWithFfmpeg_Click);
|
||||
//
|
||||
// textBoxText
|
||||
// textBoxGenerate
|
||||
//
|
||||
this.textBoxGenerate.AllowDrop = true;
|
||||
this.textBoxGenerate.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
|
||||
@ -219,7 +273,7 @@
|
||||
this.textBoxGenerate.Name = "textBoxGenerate";
|
||||
this.textBoxGenerate.ReadOnly = true;
|
||||
this.textBoxGenerate.ScrollBars = System.Windows.Forms.ScrollBars.Vertical;
|
||||
this.textBoxGenerate.Size = new System.Drawing.Size(337, 323);
|
||||
this.textBoxGenerate.Size = new System.Drawing.Size(337, 299);
|
||||
this.textBoxGenerate.TabIndex = 1;
|
||||
//
|
||||
// progressBar1
|
||||
@ -263,6 +317,7 @@
|
||||
this.groupBoxTimeCodes.PerformLayout();
|
||||
this.groupBoxGenerateSceneChanges.ResumeLayout(false);
|
||||
this.groupBoxGenerateSceneChanges.PerformLayout();
|
||||
((System.ComponentModel.ISupportInitialize)(this.numericUpDownThreshold)).EndInit();
|
||||
this.ResumeLayout(false);
|
||||
|
||||
}
|
||||
@ -285,5 +340,8 @@
|
||||
private System.Windows.Forms.ProgressBar progressBar1;
|
||||
private System.Windows.Forms.Button buttonDownloadFfmpeg;
|
||||
private System.Windows.Forms.TextBox textBoxIImport;
|
||||
private System.Windows.Forms.Label labelThressholdDescription;
|
||||
private System.Windows.Forms.NumericUpDown numericUpDownThreshold;
|
||||
private System.Windows.Forms.Label labelFfmpegThreshold;
|
||||
}
|
||||
}
|
||||
|
@ -41,12 +41,22 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
groupBoxTimeCodes.Text = Configuration.Settings.Language.ImportSceneChanges.TimeCodes;
|
||||
buttonDownloadFfmpeg.Text = Configuration.Settings.Language.Settings.DownloadFFmpeg;
|
||||
buttonImportWithFfmpeg.Text = Configuration.Settings.Language.ImportSceneChanges.GetSceneChangesWithFfmpeg;
|
||||
labelFfmpegThreshold.Text = Configuration.Settings.Language.ImportSceneChanges.Sensitivity;
|
||||
labelThressholdDescription.Text = Configuration.Settings.Language.ImportSceneChanges.SensitivityDescription;
|
||||
buttonOK.Text = Configuration.Settings.Language.General.Ok;
|
||||
buttonCancel.Text = Configuration.Settings.Language.General.Cancel;
|
||||
UiUtil.FixLargeFonts(this, buttonOK);
|
||||
buttonImportWithFfmpeg.Enabled = !string.IsNullOrWhiteSpace(Configuration.Settings.General.FFmpegLocation) && File.Exists(Configuration.Settings.General.FFmpegLocation);
|
||||
numericUpDownThreshold.Enabled = !string.IsNullOrWhiteSpace(Configuration.Settings.General.FFmpegLocation) && File.Exists(Configuration.Settings.General.FFmpegLocation);
|
||||
var isFfmpegAvailable = !string.IsNullOrEmpty(Configuration.Settings.General.FFmpegLocation) && File.Exists(Configuration.Settings.General.FFmpegLocation);
|
||||
buttonDownloadFfmpeg.Visible = !isFfmpegAvailable;
|
||||
decimal thresshold;
|
||||
if (decimal.TryParse(Configuration.Settings.General.FFmpegSceneThreshold, NumberStyles.AllowDecimalPoint, CultureInfo.InvariantCulture, out thresshold) &&
|
||||
thresshold >= numericUpDownThreshold.Minimum &&
|
||||
thresshold <= numericUpDownThreshold.Maximum)
|
||||
{
|
||||
numericUpDownThreshold.Value = thresshold;
|
||||
}
|
||||
}
|
||||
|
||||
public sealed override string Text
|
||||
@ -182,6 +192,7 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
}
|
||||
}
|
||||
}
|
||||
Configuration.Settings.General.FFmpegSceneThreshold = numericUpDownThreshold.Value.ToString(CultureInfo.InvariantCulture);
|
||||
DialogResult = DialogResult.OK;
|
||||
}
|
||||
|
||||
@ -203,13 +214,14 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
progressBar1.Visible = true;
|
||||
progressBar1.Style = ProgressBarStyle.Marquee;
|
||||
buttonImportWithFfmpeg.Enabled = false;
|
||||
numericUpDownThreshold.Enabled = false;
|
||||
Cursor = Cursors.WaitCursor;
|
||||
textBoxGenerate.Text = string.Empty;
|
||||
_timeCodes = new StringBuilder();
|
||||
using (var process = new Process())
|
||||
{
|
||||
process.StartInfo.FileName = Configuration.Settings.General.FFmpegLocation;
|
||||
process.StartInfo.Arguments = $"-i \"{_videoFileName}\" -vf \"select=gt(scene\\," + Configuration.Settings.General.FFmpegSceneThreshold + "),showinfo\" -vsync vfr -f null -";
|
||||
process.StartInfo.Arguments = $"-i \"{_videoFileName}\" -vf \"select=gt(scene\\," + numericUpDownThreshold.Value.ToString(CultureInfo.InvariantCulture) + "),showinfo\" -vsync vfr -f null -";
|
||||
process.StartInfo.UseShellExecute = false;
|
||||
process.StartInfo.RedirectStandardOutput = true;
|
||||
process.StartInfo.RedirectStandardError = true;
|
||||
@ -283,6 +295,7 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
Configuration.Settings.General.FFmpegLocation = form.FFmpegPath;
|
||||
buttonDownloadFfmpeg.Visible = false;
|
||||
buttonImportWithFfmpeg.Enabled = true;
|
||||
numericUpDownThreshold.Enabled = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user