diff --git a/ShareX.MediaLib/Forms/VideoConverterForm.Designer.cs b/ShareX.MediaLib/Forms/VideoConverterForm.Designer.cs index 480312b96..23ae551d2 100644 --- a/ShareX.MediaLib/Forms/VideoConverterForm.Designer.cs +++ b/ShareX.MediaLib/Forms/VideoConverterForm.Designer.cs @@ -47,15 +47,16 @@ private void InitializeComponent() this.lvlVideoQualityLower = new System.Windows.Forms.Label(); this.tcMain = new System.Windows.Forms.TabControl(); this.tpVideoOptions = new System.Windows.Forms.TabPage(); - this.tpArguments = new System.Windows.Forms.TabPage(); this.tpOptions = new System.Windows.Forms.TabPage(); - this.pbProgress = new ShareX.HelpersLib.BlackStyleProgressBar(); this.cbAutoOpenFolder = new System.Windows.Forms.CheckBox(); + this.tpArguments = new System.Windows.Forms.TabPage(); + this.pbProgress = new ShareX.HelpersLib.BlackStyleProgressBar(); + this.cbUseCustomArguments = new System.Windows.Forms.CheckBox(); ((System.ComponentModel.ISupportInitialize)(this.tbVideoQuality)).BeginInit(); this.tcMain.SuspendLayout(); this.tpVideoOptions.SuspendLayout(); - this.tpArguments.SuspendLayout(); this.tpOptions.SuspendLayout(); + this.tpArguments.SuspendLayout(); this.SuspendLayout(); // // lblInputFilePath @@ -171,12 +172,13 @@ private void InitializeComponent() // txtArguments // this.txtArguments.Font = new System.Drawing.Font("Verdana", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.txtArguments.Location = new System.Drawing.Point(8, 8); + this.txtArguments.Location = new System.Drawing.Point(8, 32); this.txtArguments.Multiline = true; this.txtArguments.Name = "txtArguments"; this.txtArguments.ReadOnly = true; - this.txtArguments.Size = new System.Drawing.Size(400, 136); + this.txtArguments.Size = new System.Drawing.Size(400, 112); this.txtArguments.TabIndex = 16; + this.txtArguments.TextChanged += new System.EventHandler(this.txtArguments_TextChanged); // // tbVideoQuality // @@ -243,17 +245,6 @@ private void InitializeComponent() this.tpVideoOptions.Text = "Video options"; this.tpVideoOptions.UseVisualStyleBackColor = true; // - // tpArguments - // - this.tpArguments.Controls.Add(this.txtArguments); - this.tpArguments.Location = new System.Drawing.Point(4, 22); - this.tpArguments.Name = "tpArguments"; - this.tpArguments.Padding = new System.Windows.Forms.Padding(3); - this.tpArguments.Size = new System.Drawing.Size(416, 150); - this.tpArguments.TabIndex = 1; - this.tpArguments.Text = "Arguments"; - this.tpArguments.UseVisualStyleBackColor = true; - // // tpOptions // this.tpOptions.Controls.Add(this.cbAutoOpenFolder); @@ -265,6 +256,29 @@ private void InitializeComponent() this.tpOptions.Text = "Options"; this.tpOptions.UseVisualStyleBackColor = true; // + // cbAutoOpenFolder + // + this.cbAutoOpenFolder.AutoSize = true; + this.cbAutoOpenFolder.Location = new System.Drawing.Point(16, 16); + this.cbAutoOpenFolder.Name = "cbAutoOpenFolder"; + this.cbAutoOpenFolder.Size = new System.Drawing.Size(152, 17); + this.cbAutoOpenFolder.TabIndex = 0; + this.cbAutoOpenFolder.Text = "Open folder after encoding"; + this.cbAutoOpenFolder.UseVisualStyleBackColor = true; + this.cbAutoOpenFolder.CheckedChanged += new System.EventHandler(this.cbAutoOpenFolder_CheckedChanged); + // + // tpArguments + // + this.tpArguments.Controls.Add(this.cbUseCustomArguments); + this.tpArguments.Controls.Add(this.txtArguments); + this.tpArguments.Location = new System.Drawing.Point(4, 22); + this.tpArguments.Name = "tpArguments"; + this.tpArguments.Padding = new System.Windows.Forms.Padding(3); + this.tpArguments.Size = new System.Drawing.Size(416, 150); + this.tpArguments.TabIndex = 1; + this.tpArguments.Text = "Arguments"; + this.tpArguments.UseVisualStyleBackColor = true; + // // pbProgress // this.pbProgress.Font = new System.Drawing.Font("Arial", 11.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); @@ -276,16 +290,16 @@ private void InitializeComponent() this.pbProgress.TabIndex = 19; this.pbProgress.Text = null; // - // cbAutoOpenFolder + // cbUseCustomArguments // - this.cbAutoOpenFolder.AutoSize = true; - this.cbAutoOpenFolder.Location = new System.Drawing.Point(16, 16); - this.cbAutoOpenFolder.Name = "cbAutoOpenFolder"; - this.cbAutoOpenFolder.Size = new System.Drawing.Size(152, 17); - this.cbAutoOpenFolder.TabIndex = 0; - this.cbAutoOpenFolder.Text = "Open folder after encoding"; - this.cbAutoOpenFolder.UseVisualStyleBackColor = true; - this.cbAutoOpenFolder.CheckedChanged += new System.EventHandler(this.cbAutoOpenFolder_CheckedChanged); + this.cbUseCustomArguments.AutoSize = true; + this.cbUseCustomArguments.Location = new System.Drawing.Point(8, 8); + this.cbUseCustomArguments.Name = "cbUseCustomArguments"; + this.cbUseCustomArguments.Size = new System.Drawing.Size(134, 17); + this.cbUseCustomArguments.TabIndex = 17; + this.cbUseCustomArguments.Text = "Use custom arguments"; + this.cbUseCustomArguments.UseVisualStyleBackColor = true; + this.cbUseCustomArguments.CheckedChanged += new System.EventHandler(this.cbUseCustomArguments_CheckedChanged); // // VideoConverterForm // @@ -314,10 +328,10 @@ private void InitializeComponent() this.tcMain.ResumeLayout(false); this.tpVideoOptions.ResumeLayout(false); this.tpVideoOptions.PerformLayout(); - this.tpArguments.ResumeLayout(false); - this.tpArguments.PerformLayout(); this.tpOptions.ResumeLayout(false); this.tpOptions.PerformLayout(); + this.tpArguments.ResumeLayout(false); + this.tpArguments.PerformLayout(); this.ResumeLayout(false); this.PerformLayout(); @@ -348,5 +362,6 @@ private void InitializeComponent() private System.Windows.Forms.TabPage tpOptions; private HelpersLib.BlackStyleProgressBar pbProgress; private System.Windows.Forms.CheckBox cbAutoOpenFolder; + private System.Windows.Forms.CheckBox cbUseCustomArguments; } } \ No newline at end of file diff --git a/ShareX.MediaLib/Forms/VideoConverterForm.cs b/ShareX.MediaLib/Forms/VideoConverterForm.cs index 1c8ce51d3..69cd6225e 100644 --- a/ShareX.MediaLib/Forms/VideoConverterForm.cs +++ b/ShareX.MediaLib/Forms/VideoConverterForm.cs @@ -58,6 +58,13 @@ public VideoConverterForm(string ffmpegFilePath, VideoConverterOptions options) cbAutoOpenFolder.Checked = Options.AutoOpenFolder; + cbUseCustomArguments.Checked = Options.UseCustomArguments; + + if (Options.UseCustomArguments) + { + txtArguments.Text = Options.CustomArguments; + } + formReady = true; } @@ -69,6 +76,11 @@ private void UpdateOptions() Options.OutputFolderPath = txtOutputFolder.Text; Options.OutputFileName = txtOutputFileName.Text; Options.VideoCodec = (ConverterVideoCodecs)cbVideoCodec.SelectedIndex; + Options.UseCustomArguments = cbUseCustomArguments.Checked; + if (Options.UseCustomArguments) + { + Options.CustomArguments = txtArguments.Text; + } } switch (Options.VideoCodec) @@ -110,7 +122,12 @@ private void UpdateOptions() lblVideoQualityValue.Text = Options.VideoQuality.ToString(); - txtArguments.Text = Options.GetFFmpegArgs(); + if (!Options.UseCustomArguments) + { + txtArguments.Text = Options.GetFFmpegArgs(); + } + + txtArguments.ReadOnly = !Options.UseCustomArguments; btnEncode.Enabled = !string.IsNullOrEmpty(Options.InputFilePath) && !string.IsNullOrEmpty(Options.OutputFolderPath) && !string.IsNullOrEmpty(Options.OutputFileName); @@ -130,7 +147,7 @@ private bool StartEncoding() ffmpeg.EncodeProgressChanged += Manager_EncodeProgressChanged; string outputFilePath = Options.OutputFilePath; - string args = Options.GetFFmpegArgs(); + string args = Options.Arguments; result = ffmpeg.Run(args); if (Options.AutoOpenFolder && result && !ffmpeg.StopRequested) @@ -213,6 +230,16 @@ private void cbAutoOpenFolder_CheckedChanged(object sender, EventArgs e) Options.AutoOpenFolder = cbAutoOpenFolder.Checked; } + private void cbUseCustomArguments_CheckedChanged(object sender, EventArgs e) + { + UpdateOptions(); + } + + private void txtArguments_TextChanged(object sender, EventArgs e) + { + UpdateOptions(); + } + private async void btnEncode_Click(object sender, EventArgs e) { if (!encoding) diff --git a/ShareX.MediaLib/VideoConverterOptions.cs b/ShareX.MediaLib/VideoConverterOptions.cs index e022f33b6..d616ae90a 100644 --- a/ShareX.MediaLib/VideoConverterOptions.cs +++ b/ShareX.MediaLib/VideoConverterOptions.cs @@ -55,6 +55,22 @@ public string OutputFilePath public bool AutoOpenFolder { get; set; } = true; + public bool UseCustomArguments { get; set; } = false; + public string CustomArguments { get; set; } = ""; + + public string Arguments + { + get + { + if (UseCustomArguments) + { + return CustomArguments; + } + + return GetFFmpegArgs(); + } + } + public string GetFFmpegArgs() { StringBuilder args = new StringBuilder();