From 5a395ed5bc1bf9f5952ecfe307c68e4ebe424d1d Mon Sep 17 00:00:00 2001 From: Jaex Date: Thu, 25 Jun 2015 17:06:26 +0300 Subject: [PATCH] FFmpeg UI changes --- .../Screencast/FFmpegHelper.cs | 4 +- .../Screencast/FFmpegOptionsForm.Designer.cs | 48 ++-- .../Screencast/FFmpegOptionsForm.cs | 22 +- .../Screencast/FFmpegOptionsForm.resx | 260 +++++++++--------- 4 files changed, 174 insertions(+), 160 deletions(-) diff --git a/ShareX.ScreenCaptureLib/Screencast/FFmpegHelper.cs b/ShareX.ScreenCaptureLib/Screencast/FFmpegHelper.cs index 9f8cb917d..805c69a24 100644 --- a/ShareX.ScreenCaptureLib/Screencast/FFmpegHelper.cs +++ b/ShareX.ScreenCaptureLib/Screencast/FFmpegHelper.cs @@ -36,11 +36,13 @@ namespace ShareX.ScreenCaptureLib { public class FFmpegHelper : ExternalCLIManager { - public const int libmp3lame_qscale_end = 9; public const string SourceNone = "None"; public const string SourceGDIGrab = "GDI grab"; public const string SourceVideoDevice = "screen-capture-recorder"; public const string SourceAudioDevice = "virtual-audio-capturer"; + public const string DeviceSetupPath = "Screen Capture Recorder setup.exe"; + + public const int libmp3lame_qscale_end = 9; public StringBuilder Output { get; private set; } public ScreencastOptions Options { get; private set; } diff --git a/ShareX.ScreenCaptureLib/Screencast/FFmpegOptionsForm.Designer.cs b/ShareX.ScreenCaptureLib/Screencast/FFmpegOptionsForm.Designer.cs index 2bec09e48..8614b393f 100644 --- a/ShareX.ScreenCaptureLib/Screencast/FFmpegOptionsForm.Designer.cs +++ b/ShareX.ScreenCaptureLib/Screencast/FFmpegOptionsForm.Designer.cs @@ -80,13 +80,13 @@ private void InitializeComponent() this.cboAudioCodec = new System.Windows.Forms.ComboBox(); this.lblAudioCodec = new System.Windows.Forms.Label(); this.gbSource = new System.Windows.Forms.GroupBox(); + this.btnHelperDevicesHelp = new System.Windows.Forms.Button(); + this.lblHelperDevices = new System.Windows.Forms.Label(); + this.btnInstallHelperDevices = new System.Windows.Forms.Button(); this.btnRefreshSources = new System.Windows.Forms.Button(); this.gbCodecs = new System.Windows.Forms.GroupBox(); this.btnHelp = new System.Windows.Forms.Button(); this.eiFFmpeg = new ShareX.HelpersLib.ExportImportControl(); - this.btnInstallHelperDevices = new System.Windows.Forms.Button(); - this.lblHelperDevices = new System.Windows.Forms.Label(); - this.btnHelperDevicesHelp = new System.Windows.Forms.Button(); ((System.ComponentModel.ISupportInitialize)(this.nudx264CRF)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.nudXvidQscale)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.tbVorbis_qscale)).BeginInit(); @@ -532,6 +532,25 @@ private void InitializeComponent() this.gbSource.Name = "gbSource"; this.gbSource.TabStop = false; // + // btnHelperDevicesHelp + // + resources.ApplyResources(this.btnHelperDevicesHelp, "btnHelperDevicesHelp"); + this.btnHelperDevicesHelp.Name = "btnHelperDevicesHelp"; + this.btnHelperDevicesHelp.UseVisualStyleBackColor = true; + this.btnHelperDevicesHelp.Click += new System.EventHandler(this.btnHelperDevicesHelp_Click); + // + // lblHelperDevices + // + resources.ApplyResources(this.lblHelperDevices, "lblHelperDevices"); + this.lblHelperDevices.Name = "lblHelperDevices"; + // + // btnInstallHelperDevices + // + resources.ApplyResources(this.btnInstallHelperDevices, "btnInstallHelperDevices"); + this.btnInstallHelperDevices.Name = "btnInstallHelperDevices"; + this.btnInstallHelperDevices.UseVisualStyleBackColor = true; + this.btnInstallHelperDevices.Click += new System.EventHandler(this.btnInstallHelperDevices_Click); + // // btnRefreshSources // resources.ApplyResources(this.btnRefreshSources, "btnRefreshSources"); @@ -545,6 +564,8 @@ private void InitializeComponent() this.gbCodecs.Controls.Add(this.lblAudioCodec); this.gbCodecs.Controls.Add(this.cboVideoCodec); this.gbCodecs.Controls.Add(this.lblCodec); + this.gbCodecs.Controls.Add(this.tcFFmpegAudioCodecs); + this.gbCodecs.Controls.Add(this.tcFFmpegVideoCodecs); resources.ApplyResources(this.gbCodecs, "gbCodecs"); this.gbCodecs.Name = "gbCodecs"; this.gbCodecs.TabStop = false; @@ -564,25 +585,6 @@ private void InitializeComponent() this.eiFFmpeg.ExportRequested += new ShareX.HelpersLib.ExportImportControl.ExportEventHandler(this.eiFFmpeg_ExportRequested); this.eiFFmpeg.ImportRequested += new ShareX.HelpersLib.ExportImportControl.ImportEventHandler(this.eiFFmpeg_ImportRequested); // - // btnInstallHelperDevices - // - resources.ApplyResources(this.btnInstallHelperDevices, "btnInstallHelperDevices"); - this.btnInstallHelperDevices.Name = "btnInstallHelperDevices"; - this.btnInstallHelperDevices.UseVisualStyleBackColor = true; - this.btnInstallHelperDevices.Click += new System.EventHandler(this.btnInstallHelperDevices_Click); - // - // lblHelperDevices - // - resources.ApplyResources(this.lblHelperDevices, "lblHelperDevices"); - this.lblHelperDevices.Name = "lblHelperDevices"; - // - // btnHelperDevicesHelp - // - resources.ApplyResources(this.btnHelperDevicesHelp, "btnHelperDevicesHelp"); - this.btnHelperDevicesHelp.Name = "btnHelperDevicesHelp"; - this.btnHelperDevicesHelp.UseVisualStyleBackColor = true; - this.btnHelperDevicesHelp.Click += new System.EventHandler(this.btnHelperDevicesHelp_Click); - // // FFmpegOptionsForm // resources.ApplyResources(this, "$this"); @@ -592,10 +594,8 @@ private void InitializeComponent() this.Controls.Add(this.btnHelp); this.Controls.Add(this.gbCodecs); this.Controls.Add(this.gbSource); - this.Controls.Add(this.tcFFmpegAudioCodecs); this.Controls.Add(this.btnCopyPreview); this.Controls.Add(this.btnTest); - this.Controls.Add(this.tcFFmpegVideoCodecs); this.Controls.Add(this.gbCommandLinePreview); this.Controls.Add(this.gbFFmpegExe); this.Controls.Add(this.gbCommandLineArgs); diff --git a/ShareX.ScreenCaptureLib/Screencast/FFmpegOptionsForm.cs b/ShareX.ScreenCaptureLib/Screencast/FFmpegOptionsForm.cs index fb7b8dc18..f65ed2661 100644 --- a/ShareX.ScreenCaptureLib/Screencast/FFmpegOptionsForm.cs +++ b/ShareX.ScreenCaptureLib/Screencast/FFmpegOptionsForm.cs @@ -35,17 +35,17 @@ namespace ShareX.ScreenCaptureLib { public partial class FFmpegOptionsForm : Form { - public ScreencastOptions Options = new ScreencastOptions(); - public string DefaultToolsPath; + public ScreencastOptions Options { get; private set; } + public string DefaultToolsPath { get; set; } private bool settingsLoaded; - private bool devicesInstalled; public FFmpegOptionsForm(ScreencastOptions options) { InitializeComponent(); Icon = ShareXResources.Icon; Options = options; + eiFFmpeg.ObjectType = typeof(FFmpegOptions); cboVideoCodec.Items.AddRange(Helpers.GetEnumDescriptions()); cboAudioCodec.Items.AddRange(Helpers.GetEnumDescriptions()); @@ -73,6 +73,7 @@ private void SettingsLoad() } txtFFmpegPath.Text = Options.FFmpeg.CLIPath; + txtFFmpegPath.SelectionStart = txtFFmpegPath.TextLength; tbUserArgs.Text = Options.FFmpeg.UserArgs; @@ -111,7 +112,7 @@ private void SettingsLoad() UpdateUI(); } - private void RefreshSourcesAsync() + private void RefreshSourcesAsync(bool selectDevices = false) { btnRefreshSources.Enabled = false; DirectShowDevices devices = null; @@ -130,27 +131,27 @@ private void RefreshSourcesAsync() cboVideoSource.Items.Add(FFmpegHelper.SourceGDIGrab); cboAudioSource.Items.Clear(); cboAudioSource.Items.Add(FFmpegHelper.SourceNone); + if (devices != null) { cboVideoSource.Items.AddRange(devices.VideoDevices.ToArray()); cboAudioSource.Items.AddRange(devices.AudioDevices.ToArray()); } - if (devicesInstalled && cboVideoSource.Items.Contains(FFmpegHelper.SourceVideoDevice)) + if (selectDevices && cboVideoSource.Items.Contains(FFmpegHelper.SourceVideoDevice)) { Options.FFmpeg.VideoSource = FFmpegHelper.SourceVideoDevice; } cboVideoSource.Text = Options.FFmpeg.VideoSource; - if (devicesInstalled && cboAudioSource.Items.Contains(FFmpegHelper.SourceAudioDevice)) + if (selectDevices && cboAudioSource.Items.Contains(FFmpegHelper.SourceAudioDevice)) { Options.FFmpeg.AudioSource = FFmpegHelper.SourceAudioDevice; } cboAudioSource.Text = Options.FFmpeg.AudioSource; - devicesInstalled = false; btnRefreshSources.Enabled = true; }); } @@ -189,7 +190,7 @@ private void cboAudioSource_SelectedIndexChanged(object sender, EventArgs e) private void btnInstallHelperDevices_Click(object sender, EventArgs e) { - string filepath = Helpers.GetAbsolutePath("Screen Capture Recorder setup.exe"); + string filepath = Helpers.GetAbsolutePath(FFmpegHelper.DeviceSetupPath); if (!string.IsNullOrEmpty(filepath) && File.Exists(filepath)) { @@ -199,12 +200,11 @@ private void btnInstallHelperDevices_Click(object sender, EventArgs e) { Process process = Process.Start(filepath); - if (process.WaitForExit(1000 * 60 * 5)) + if (process.WaitForExit(1000 * 60 * 5) && process.ExitCode == 0) { this.InvokeSafe(() => { - devicesInstalled = true; - RefreshSourcesAsync(); + RefreshSourcesAsync(true); }); } } diff --git a/ShareX.ScreenCaptureLib/Screencast/FFmpegOptionsForm.resx b/ShareX.ScreenCaptureLib/Screencast/FFmpegOptionsForm.resx index 52457ed3b..e98b5f9b3 100644 --- a/ShareX.ScreenCaptureLib/Screencast/FFmpegOptionsForm.resx +++ b/ShareX.ScreenCaptureLib/Screencast/FFmpegOptionsForm.resx @@ -242,7 +242,7 @@ Similarly, for constant quality encoding, you will simply save bitrate by choosi Right - 112, 3 + 104, 3 197, 64 @@ -269,7 +269,7 @@ Similarly, for constant quality encoding, you will simply save bitrate by choosi Right - 112, 3 + 104, 3 197, 64 @@ -296,7 +296,7 @@ Similarly, for constant quality encoding, you will simply save bitrate by choosi Right - 112, 3 + 104, 3 197, 64 @@ -380,7 +380,7 @@ Default is sierra2_4a. True - 8, 26 + 8, 24 70, 13 @@ -404,10 +404,10 @@ Default is sierra2_4a. 3 - 88, 22 + 120, 20 - 88, 21 + 104, 21 1 @@ -478,66 +478,6 @@ Default is sierra2_4a. 1 - - btnDownload - - - System.Windows.Forms.Button, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - gbFFmpegExe - - - 0 - - - btnFFmpegBrowse - - - System.Windows.Forms.Button, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - gbFFmpegExe - - - 1 - - - txtFFmpegPath - - - System.Windows.Forms.TextBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - gbFFmpegExe - - - 2 - - - 8, 8 - - - 648, 56 - - - 0 - - - ffmpeg.exe - - - gbFFmpegExe - - - System.Windows.Forms.GroupBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - $this - - - 9 - 552, 22 @@ -563,10 +503,10 @@ Default is sierra2_4a. 0 - 504, 22 + 512, 22 - 40, 24 + 32, 24 1 @@ -590,7 +530,7 @@ Default is sierra2_4a. 8, 24 - 488, 20 + 496, 20 0 @@ -607,6 +547,30 @@ Default is sierra2_4a. 2 + + 8, 8 + + + 648, 56 + + + 0 + + + FFmpeg path + + + gbFFmpegExe + + + System.Windows.Forms.GroupBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + $this + + + 7 + cbCustomCommands @@ -656,13 +620,13 @@ Default is sierra2_4a. $this - 8 + 6 True - 320, 0 + 376, 0 136, 17 @@ -764,16 +728,16 @@ Default is sierra2_4a. $this - 10 + 8 Top, Right - 600, 22 + 616, 23 - 40, 24 + 24, 23 1 @@ -800,7 +764,7 @@ Default is sierra2_4a. 8, 24 - 584, 20 + 600, 20 0 @@ -866,10 +830,10 @@ Default is sierra2_4a. 3 - 8, 232 + 8, 56 - 320, 96 + 312, 96 3 @@ -881,10 +845,10 @@ Default is sierra2_4a. System.Windows.Forms.TabControl, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - $this + gbCodecs - 7 + 5 4, 22 @@ -893,7 +857,7 @@ Default is sierra2_4a. 3, 3, 3, 3 - 312, 70 + 304, 70 1 @@ -953,13 +917,13 @@ Default is sierra2_4a. 4, 22 - 312, 70 + 304, 70 2 - VP8 (WebM) + VP8 tpVpx @@ -1058,7 +1022,7 @@ Default is sierra2_4a. 4, 22 - 312, 70 + 304, 70 3 @@ -1109,7 +1073,7 @@ Default is sierra2_4a. 3, 3, 3, 3 - 312, 70 + 304, 70 4 @@ -1190,7 +1154,7 @@ Default is sierra2_4a. 176, 404 - 88, 23 + 120, 23 7 @@ -1208,13 +1172,13 @@ Default is sierra2_4a. $this - 6 + 5 - 267, 404 + 304, 404 - 53, 23 + 72, 23 8 @@ -1232,7 +1196,7 @@ Default is sierra2_4a. $this - 5 + 4 tpAAC @@ -1271,10 +1235,10 @@ Default is sierra2_4a. 2 - 336, 232 + 328, 56 - 320, 96 + 312, 96 4 @@ -1286,7 +1250,7 @@ Default is sierra2_4a. System.Windows.Forms.TabControl, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - $this + gbCodecs 4 @@ -1310,7 +1274,7 @@ Default is sierra2_4a. 3, 3, 3, 3 - 312, 70 + 304, 70 3 @@ -1376,7 +1340,7 @@ Default is sierra2_4a. 3, 3, 3, 3 - 312, 70 + 304, 70 0 @@ -1442,7 +1406,7 @@ Default is sierra2_4a. 3, 3, 3, 3 - 312, 70 + 304, 70 2 @@ -1586,10 +1550,10 @@ Default is sierra2_4a. 6 - 264, 22 + 440, 20 - 88, 21 + 104, 21 3 @@ -1610,7 +1574,7 @@ Default is sierra2_4a. True - 184, 26 + 328, 24 70, 13 @@ -1633,6 +1597,78 @@ Default is sierra2_4a. 1 + + btnHelperDevicesHelp + + + System.Windows.Forms.Button, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + gbSource + + + 0 + + + lblHelperDevices + + + System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + gbSource + + + 1 + + + btnInstallHelperDevices + + + System.Windows.Forms.Button, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + gbSource + + + 2 + + + btnRefreshSources + + + System.Windows.Forms.Button, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + gbSource + + + 7 + + + 8, 68 + + + 648, 92 + + + 1 + + + Sources + + + gbSource + + + System.Windows.Forms.GroupBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + $this + + + 3 + 168, 56 @@ -1694,7 +1730,7 @@ Default is sierra2_4a. 5 - Install helper devices + Install record devices btnInstallHelperDevices @@ -1732,35 +1768,11 @@ Default is sierra2_4a. 7 - - 8, 68 - - - 648, 92 - - - 1 - - - Sources - - - gbSource - - - System.Windows.Forms.GroupBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - $this - - - 3 - 8, 168 - 648, 56 + 648, 160 2