From 0e2ae37c089be10b116197baddb931884cf3e14c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=82=BB=E3=83=90=E3=82=B9=E3=83=81=E3=83=A3=E3=83=B3?= Date: Sat, 7 Oct 2023 09:04:20 -0500 Subject: [PATCH] Add option to convert audio in mono channel #53 --- MainForm.Designer.cs | 67 +++++++++++------- MainForm.cs | 10 ++- MainForm.resx | 158 +++++++++++++++++++++++++++++++++++++++---- 3 files changed, 196 insertions(+), 39 deletions(-) diff --git a/MainForm.Designer.cs b/MainForm.Designer.cs index 9188c67..6e840b2 100644 --- a/MainForm.Designer.cs +++ b/MainForm.Designer.cs @@ -63,6 +63,7 @@ private void InitializeComponent() System.Windows.Forms.Label labelVideoCrfToleranceHint; System.Windows.Forms.GroupBox groupEncodingAudio; System.Windows.Forms.TableLayoutPanel tableEncodingAudio; + System.Windows.Forms.Label labelNormalization; System.Windows.Forms.Panel panelEncodingModeSwapperTwo; System.Windows.Forms.Label labelAudioBitrate; System.Windows.Forms.Label labelAudioBitrateUnit; @@ -87,7 +88,6 @@ private void InitializeComponent() System.Windows.Forms.GroupBox groupBox1; System.Windows.Forms.GroupBox groupBox2; System.Windows.Forms.StatusStrip statusStrip; - System.Windows.Forms.Label labelNormalization; this.textBoxIn = new System.Windows.Forms.TextBox(); this.buttonBrowseIn = new System.Windows.Forms.Button(); this.textBoxOut = new System.Windows.Forms.TextBox(); @@ -127,6 +127,7 @@ private void InitializeComponent() this.boxHQ = new System.Windows.Forms.CheckBox(); this.checkMP4 = new System.Windows.Forms.CheckBox(); this.checkHWAcceleration = new System.Windows.Forms.CheckBox(); + this.boxMono = new System.Windows.Forms.CheckBox(); this.numericNormalization = new System.Windows.Forms.NumericUpDown(); this.boxAudio = new System.Windows.Forms.CheckBox(); this.tableAudioConstantOptions = new System.Windows.Forms.TableLayoutPanel(); @@ -244,6 +245,7 @@ private void InitializeComponent() labelVideoCrfToleranceHint = new System.Windows.Forms.Label(); groupEncodingAudio = new System.Windows.Forms.GroupBox(); tableEncodingAudio = new System.Windows.Forms.TableLayoutPanel(); + labelNormalization = new System.Windows.Forms.Label(); panelEncodingModeSwapperTwo = new System.Windows.Forms.Panel(); labelAudioBitrate = new System.Windows.Forms.Label(); labelAudioBitrateUnit = new System.Windows.Forms.Label(); @@ -268,7 +270,6 @@ private void InitializeComponent() groupBox1 = new System.Windows.Forms.GroupBox(); groupBox2 = new System.Windows.Forms.GroupBox(); statusStrip = new System.Windows.Forms.StatusStrip(); - labelNormalization = new System.Windows.Forms.Label(); tableMainForm.SuspendLayout(); groupMain.SuspendLayout(); tableMain.SuspendLayout(); @@ -1355,11 +1356,12 @@ private void InitializeComponent() tableEncodingAudio.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 89F)); tableEncodingAudio.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 73F)); tableEncodingAudio.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 100F)); - tableEncodingAudio.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 115F)); + tableEncodingAudio.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 153F)); tableEncodingAudio.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 76F)); tableEncodingAudio.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 621F)); - tableEncodingAudio.Controls.Add(labelNormalization, 3, 0); - tableEncodingAudio.Controls.Add(this.numericNormalization, 5, 0); + tableEncodingAudio.Controls.Add(this.boxMono, 3, 0); + tableEncodingAudio.Controls.Add(labelNormalization, 5, 0); + tableEncodingAudio.Controls.Add(this.numericNormalization, 6, 0); tableEncodingAudio.Controls.Add(this.boxAudio, 0, 0); tableEncodingAudio.Controls.Add(panelEncodingModeSwapperTwo, 0, 1); tableEncodingAudio.Controls.Add(this.numericDelay, 3, 0); @@ -1377,6 +1379,34 @@ private void InitializeComponent() tableEncodingAudio.Size = new System.Drawing.Size(1383, 66); tableEncodingAudio.TabIndex = 0; // + // boxMono + // + this.boxMono.AutoSize = true; + this.boxMono.CheckAlign = System.Drawing.ContentAlignment.MiddleRight; + this.boxMono.Dock = System.Windows.Forms.DockStyle.Right; + this.boxMono.Enabled = false; + this.boxMono.Location = new System.Drawing.Point(426, 4); + this.boxMono.Margin = new System.Windows.Forms.Padding(4); + this.boxMono.Name = "boxMono"; + this.boxMono.Size = new System.Drawing.Size(103, 26); + this.boxMono.TabIndex = 23; + this.boxMono.Text = "Mono audio:"; + this.boxMono.TextAlign = System.Drawing.ContentAlignment.MiddleRight; + this.boxMono.UseVisualStyleBackColor = true; + this.boxMono.CheckedChanged += new System.EventHandler(this.boxMono_CheckedChanged); + // + // labelNormalization + // + labelNormalization.AutoSize = true; + labelNormalization.Dock = System.Windows.Forms.DockStyle.Fill; + labelNormalization.Location = new System.Drawing.Point(537, 0); + labelNormalization.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); + labelNormalization.Name = "labelNormalization"; + labelNormalization.Size = new System.Drawing.Size(145, 34); + labelNormalization.TabIndex = 22; + labelNormalization.Text = "Normalization:"; + labelNormalization.TextAlign = System.Drawing.ContentAlignment.MiddleRight; + // // numericNormalization // this.numericNormalization.DecimalPlaces = 2; @@ -1387,7 +1417,7 @@ private void InitializeComponent() 0, 0, 131072}); - this.numericNormalization.Location = new System.Drawing.Point(574, 5); + this.numericNormalization.Location = new System.Drawing.Point(689, 5); this.numericNormalization.Margin = new System.Windows.Forms.Padding(3, 5, 3, 2); this.numericNormalization.Maximum = new decimal(new int[] { 1, @@ -1400,7 +1430,7 @@ private void InitializeComponent() 0, -2147483648}); this.numericNormalization.Name = "numericNormalization"; - this.numericNormalization.Size = new System.Drawing.Size(109, 22); + this.numericNormalization.Size = new System.Drawing.Size(70, 22); this.numericNormalization.TabIndex = 21; this.numericNormalization.Value = new decimal(new int[] { 1, @@ -1433,7 +1463,7 @@ private void InitializeComponent() panelEncodingModeSwapperTwo.Location = new System.Drawing.Point(0, 34); panelEncodingModeSwapperTwo.Margin = new System.Windows.Forms.Padding(0); panelEncodingModeSwapperTwo.Name = "panelEncodingModeSwapperTwo"; - panelEncodingModeSwapperTwo.Size = new System.Drawing.Size(571, 34); + panelEncodingModeSwapperTwo.Size = new System.Drawing.Size(533, 34); panelEncodingModeSwapperTwo.TabIndex = 2; // // tableAudioConstantOptions @@ -1453,7 +1483,7 @@ private void InitializeComponent() this.tableAudioConstantOptions.Name = "tableAudioConstantOptions"; this.tableAudioConstantOptions.RowCount = 1; this.tableAudioConstantOptions.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100F)); - this.tableAudioConstantOptions.Size = new System.Drawing.Size(571, 34); + this.tableAudioConstantOptions.Size = new System.Drawing.Size(533, 34); this.tableAudioConstantOptions.TabIndex = 0; // // labelAudioBitrate @@ -1499,7 +1529,7 @@ private void InitializeComponent() labelAudioBitrateHint.Location = new System.Drawing.Point(306, 0); labelAudioBitrateHint.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); labelAudioBitrateHint.Name = "labelAudioBitrateHint"; - labelAudioBitrateHint.Size = new System.Drawing.Size(261, 34); + labelAudioBitrateHint.Size = new System.Drawing.Size(223, 34); labelAudioBitrateHint.TabIndex = 0; labelAudioBitrateHint.Text = "Determines the quality of the audio."; labelAudioBitrateHint.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; @@ -1520,7 +1550,7 @@ private void InitializeComponent() this.tableAudioVariableOptions.Name = "tableAudioVariableOptions"; this.tableAudioVariableOptions.RowCount = 1; this.tableAudioVariableOptions.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100F)); - this.tableAudioVariableOptions.Size = new System.Drawing.Size(571, 34); + this.tableAudioVariableOptions.Size = new System.Drawing.Size(533, 34); this.tableAudioVariableOptions.TabIndex = 0; // // labelAudioQuality @@ -1565,7 +1595,7 @@ private void InitializeComponent() labelAudioQualityHint.Location = new System.Drawing.Point(306, 0); labelAudioQualityHint.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); labelAudioQualityHint.Name = "labelAudioQualityHint"; - labelAudioQualityHint.Size = new System.Drawing.Size(261, 34); + labelAudioQualityHint.Size = new System.Drawing.Size(223, 34); labelAudioQualityHint.TabIndex = 0; labelAudioQualityHint.Text = "Determines the average quality of the audio. 10 is the highest quality."; labelAudioQualityHint.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; @@ -2831,18 +2861,6 @@ private void InitializeComponent() this.listViewContextMenuDelete.Text = "Delete"; this.listViewContextMenuDelete.Click += new System.EventHandler(this.listViewContextMenuDelete_Click); // - // labelNormalization - // - labelNormalization.AutoSize = true; - labelNormalization.Dock = System.Windows.Forms.DockStyle.Fill; - labelNormalization.Location = new System.Drawing.Point(306, 0); - labelNormalization.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); - labelNormalization.Name = "labelNormalization"; - labelNormalization.Size = new System.Drawing.Size(261, 34); - labelNormalization.TabIndex = 22; - labelNormalization.Text = "Normalization:"; - labelNormalization.TextAlign = System.Drawing.ContentAlignment.MiddleRight; - // // MainForm // this.AcceptButton = this.buttonGo; @@ -3074,6 +3092,7 @@ private void InitializeComponent() private System.Windows.Forms.CheckBox boxFixSubs; private System.Windows.Forms.ToolStripButton buttonDynamic; private System.Windows.Forms.NumericUpDown numericNormalization; + private System.Windows.Forms.CheckBox boxMono; // private System.Windows.Forms.GroupBox groupGfycat; } } diff --git a/MainForm.cs b/MainForm.cs index 80281ff..bd0a2a1 100644 --- a/MainForm.cs +++ b/MainForm.cs @@ -1443,7 +1443,7 @@ void buttonVariableDefault_Click(object sender, EventArgs e) void boxAudio_CheckedChanged(object sender, EventArgs e) { numericAudioQuality.Enabled = boxAudioBitrate.Enabled = numericDelay.Enabled = ((CheckBox)sender).Checked ; - numericNormalization.Enabled = boxAudio.Checked; + numericNormalization.Enabled = boxMono.Enabled = boxAudio.Checked; if (boxNGOV.Checked) numericAudioQuality.Enabled = false; @@ -2393,7 +2393,8 @@ string GenerateArguments() if (boxAudio.Checked) { audio = ""; - acodec = " -ac 2 -c:a " + acodec; + int channels = boxMono.Checked ? 1 : 2; + acodec = $" -ac {channels} -c:a {acodec}"; } else { @@ -3021,5 +3022,10 @@ private void buttonDynamic_Click_1(object sender, EventArgs e) } } } + + private void boxMono_CheckedChanged(object sender, EventArgs e) + { + UpdateArguments(sender, e); + } } } diff --git a/MainForm.resx b/MainForm.resx index c5c8cae..1505368 100644 --- a/MainForm.resx +++ b/MainForm.resx @@ -126,6 +126,54 @@ False + + False + + + False + + + False + + + False + + + False + + + False + + + False + + + False + + + False + + + False + + + False + + + False + + + False + + + False + + + False + + + False + False @@ -135,10 +183,13 @@ False - + False - + + False + + False @@ -150,6 +201,15 @@ 17, 17 + + False + + + False + + + 17, 17 + @@ -177,7 +237,7 @@ AAEAAAD/////AQAAAAAAAAAMAgAAAFdTeXN0ZW0uV2luZG93cy5Gb3JtcywgVmVyc2lvbj00LjAuMC4w LCBDdWx0dXJlPW5ldXRyYWwsIFB1YmxpY0tleVRva2VuPWI3N2E1YzU2MTkzNGUwODkFAQAAACZTeXN0 ZW0uV2luZG93cy5Gb3Jtcy5JbWFnZUxpc3RTdHJlYW1lcgEAAAAERGF0YQcCAgAAAAkDAAAADwMAAAAM - cwAAAk1TRnQBSQFMAgEBDAEAAaABBAGgAQQBZAEAAWQBAAT/AQkBAAj/AUIBTQE2AQQGAAE2AQQCAAEo + cwAAAk1TRnQBSQFMAgEBDAEAAbABBAGwAQQBZAEAAWQBAAT/AQkBAAj/AUIBTQE2AQQGAAE2AQQCAAEo AwABkAEBAgABkAEBAgABAQEAAQgGAAFxAQIXAAGAAgABgAMAAoABAAGAAwABgAEAAYABAAKAAgADwAEA AcAB3AHAAQAB8AHKAaYBAAEzBQABMwEAATMBAAEzAQACMwIAAxYBAAMcAQADIgEAAykBAANVAQADTQEA A0IBAAM5AQABgAF8Af8BAAJQAf8BAAGTAQAB1gEAAf8B7AHMAQABxgHWAe8BAAHWAucBAAGQAakBrQIA @@ -670,16 +730,22 @@ Mv8CADL/AgAy/wIAMv8CADL/AgAy/wIAMv8CADL/AgAy/wIAMv8CADL/AgAy/wIAMv8CADL/AgAL - + False - + False - + False - + + False + + + False + + False @@ -697,7 +763,7 @@ False - + False @@ -718,6 +784,21 @@ False + + False + + + False + + + False + + + False + + + False + False @@ -730,16 +811,25 @@ False - + False - + False - + False - + + False + + + False + + + False + + False @@ -757,7 +847,10 @@ False - + + False + + False @@ -766,9 +859,21 @@ False + + False + + + False + False + + False + + + False + False @@ -778,6 +883,33 @@ False + + False + + + False + + + False + + + False + + + False + + + False + + + False + + + False + + + False + False