2014-05-10 12:23:47 +12:00
|
|
|
|
#region License Information (GPL v3)
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
ShareX - A program that allows you to take screenshots and share any file type
|
2017-01-11 21:39:40 +13:00
|
|
|
|
Copyright (c) 2007-2017 ShareX Team
|
2014-05-10 12:23:47 +12:00
|
|
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or
|
|
|
|
|
modify it under the terms of the GNU General Public License
|
|
|
|
|
as published by the Free Software Foundation; either version 2
|
|
|
|
|
of the License, or (at your option) any later version.
|
|
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
|
along with this program; if not, write to the Free Software
|
|
|
|
|
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
|
|
|
|
|
|
Optionally you can also view the license at <http://www.gnu.org/licenses/>.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#endregion License Information (GPL v3)
|
|
|
|
|
|
2016-02-15 20:29:43 +13:00
|
|
|
|
using ShareX.HelpersLib;
|
2016-08-28 04:51:20 +12:00
|
|
|
|
using ShareX.MediaLib;
|
2016-02-15 20:29:43 +13:00
|
|
|
|
using ShareX.ScreenCaptureLib.Properties;
|
2014-05-09 15:14:53 +12:00
|
|
|
|
using System;
|
2014-05-12 22:56:37 +12:00
|
|
|
|
using System.Diagnostics;
|
2014-05-09 15:14:53 +12:00
|
|
|
|
using System.Drawing;
|
2014-05-09 22:25:04 +12:00
|
|
|
|
using System.IO;
|
2016-12-03 05:35:34 +13:00
|
|
|
|
using System.Linq;
|
2014-05-09 15:14:53 +12:00
|
|
|
|
using System.Windows.Forms;
|
|
|
|
|
|
2014-12-11 09:25:20 +13:00
|
|
|
|
namespace ShareX.ScreenCaptureLib
|
2014-05-09 15:14:53 +12:00
|
|
|
|
{
|
2016-02-26 09:55:54 +13:00
|
|
|
|
public partial class FFmpegOptionsForm : Form
|
2014-05-09 15:14:53 +12:00
|
|
|
|
{
|
2015-06-26 02:06:26 +12:00
|
|
|
|
public ScreencastOptions Options { get; private set; }
|
|
|
|
|
public string DefaultToolsPath { get; set; }
|
2014-05-09 15:14:53 +12:00
|
|
|
|
|
2014-07-03 20:33:24 +12:00
|
|
|
|
private bool settingsLoaded;
|
|
|
|
|
|
2014-05-13 20:57:05 +12:00
|
|
|
|
public FFmpegOptionsForm(ScreencastOptions options)
|
2014-05-09 15:14:53 +12:00
|
|
|
|
{
|
|
|
|
|
InitializeComponent();
|
2016-02-26 09:55:54 +13:00
|
|
|
|
Icon = ShareXResources.Icon;
|
2014-05-10 13:52:09 +12:00
|
|
|
|
Options = options;
|
2015-06-26 02:06:26 +12:00
|
|
|
|
|
2014-06-08 16:07:55 +12:00
|
|
|
|
eiFFmpeg.ObjectType = typeof(FFmpegOptions);
|
|
|
|
|
cboVideoCodec.Items.AddRange(Helpers.GetEnumDescriptions<FFmpegVideoCodec>());
|
|
|
|
|
cboAudioCodec.Items.AddRange(Helpers.GetEnumDescriptions<FFmpegAudioCodec>());
|
2015-06-09 06:19:30 +12:00
|
|
|
|
cbx264Preset.Items.AddRange(Helpers.GetEnumDescriptions<FFmpegPreset>());
|
|
|
|
|
cbGIFStatsMode.Items.AddRange(Helpers.GetEnumDescriptions<FFmpegPaletteGenStatsMode>());
|
2016-12-03 05:35:34 +13:00
|
|
|
|
cbNVENCPreset.Items.AddRange(Helpers.GetEnums<FFmpegNVENCPreset>().Select(x => $"{x} ({x.GetDescription()})").ToArray());
|
2015-06-09 06:19:30 +12:00
|
|
|
|
cbGIFDither.Items.AddRange(Helpers.GetEnumDescriptions<FFmpegPaletteUseDither>());
|
2014-05-10 13:52:09 +12:00
|
|
|
|
|
2014-07-03 20:33:24 +12:00
|
|
|
|
SettingsLoad();
|
2014-05-09 15:14:53 +12:00
|
|
|
|
}
|
|
|
|
|
|
2014-05-12 13:13:42 +12:00
|
|
|
|
private void SettingsLoad()
|
2014-05-09 15:14:53 +12:00
|
|
|
|
{
|
2014-07-03 20:33:24 +12:00
|
|
|
|
settingsLoaded = false;
|
|
|
|
|
|
2014-05-12 13:13:42 +12:00
|
|
|
|
// General
|
2014-06-08 16:07:55 +12:00
|
|
|
|
|
2015-09-13 08:32:51 +12:00
|
|
|
|
#if STEAM
|
|
|
|
|
cbOverrideFFmpegPath.Checked = Options.FFmpeg.OverrideCLIPath;
|
|
|
|
|
gbFFmpegExe.Enabled = Options.FFmpeg.OverrideCLIPath;
|
|
|
|
|
#else
|
|
|
|
|
cbOverrideFFmpegPath.Visible = false;
|
|
|
|
|
#endif
|
2014-05-10 12:23:47 +12:00
|
|
|
|
|
2014-05-14 11:48:16 +12:00
|
|
|
|
txtFFmpegPath.Text = Options.FFmpeg.CLIPath;
|
2015-06-26 02:06:26 +12:00
|
|
|
|
txtFFmpegPath.SelectionStart = txtFFmpegPath.TextLength;
|
2014-05-13 20:44:35 +12:00
|
|
|
|
|
2015-09-13 08:32:51 +12:00
|
|
|
|
RefreshSourcesAsync();
|
|
|
|
|
|
|
|
|
|
cboVideoCodec.SelectedIndex = (int)Options.FFmpeg.VideoCodec;
|
|
|
|
|
cboAudioCodec.SelectedIndex = (int)Options.FFmpeg.AudioCodec;
|
|
|
|
|
|
2014-05-13 20:44:35 +12:00
|
|
|
|
tbUserArgs.Text = Options.FFmpeg.UserArgs;
|
2014-05-12 13:13:42 +12:00
|
|
|
|
|
|
|
|
|
// x264
|
2016-03-01 10:09:22 +13:00
|
|
|
|
nudx264CRF.SetValue(Options.FFmpeg.x264_CRF);
|
2015-06-09 06:19:30 +12:00
|
|
|
|
cbx264Preset.SelectedIndex = (int)Options.FFmpeg.x264_Preset;
|
2014-05-12 13:13:42 +12:00
|
|
|
|
|
|
|
|
|
// VPx
|
2016-03-01 10:09:22 +13:00
|
|
|
|
nudVP8Bitrate.SetValue(Options.FFmpeg.VPx_bitrate);
|
2014-05-12 13:13:42 +12:00
|
|
|
|
|
2014-05-30 19:41:32 +12:00
|
|
|
|
// Xvid
|
2016-03-01 10:09:22 +13:00
|
|
|
|
nudXvidQscale.SetValue(Options.FFmpeg.XviD_qscale);
|
2015-06-09 06:19:30 +12:00
|
|
|
|
|
2016-12-03 05:35:34 +13:00
|
|
|
|
// NVENC
|
|
|
|
|
nudNVENCBitrate.SetValue(Options.FFmpeg.NVENC_bitrate);
|
|
|
|
|
cbNVENCPreset.SelectedIndex = (int)Options.FFmpeg.NVENC_preset;
|
|
|
|
|
|
2015-06-09 06:19:30 +12:00
|
|
|
|
// GIF
|
|
|
|
|
cbGIFStatsMode.SelectedIndex = (int)Options.FFmpeg.GIFStatsMode;
|
|
|
|
|
cbGIFDither.SelectedIndex = (int)Options.FFmpeg.GIFDither;
|
2014-05-13 23:50:31 +12:00
|
|
|
|
|
2014-05-15 18:13:49 +12:00
|
|
|
|
// AAC
|
|
|
|
|
tbAACBitrate.Value = Options.FFmpeg.AAC_bitrate / 32;
|
|
|
|
|
|
|
|
|
|
// Vorbis
|
2014-05-13 23:50:31 +12:00
|
|
|
|
tbVorbis_qscale.Value = Options.FFmpeg.Vorbis_qscale;
|
|
|
|
|
|
2014-05-15 18:13:49 +12:00
|
|
|
|
// MP3
|
2014-07-03 20:33:24 +12:00
|
|
|
|
tbMP3_qscale.Value = FFmpegHelper.libmp3lame_qscale_end - Options.FFmpeg.MP3_qscale;
|
|
|
|
|
|
2014-06-04 11:18:41 +12:00
|
|
|
|
cbCustomCommands.Checked = Options.FFmpeg.UseCustomCommands;
|
|
|
|
|
|
2014-06-08 07:29:26 +12:00
|
|
|
|
if (Options.FFmpeg.UseCustomCommands)
|
|
|
|
|
{
|
|
|
|
|
txtCommandLinePreview.Text = Options.FFmpeg.CustomCommands;
|
|
|
|
|
}
|
|
|
|
|
|
2014-07-03 20:33:24 +12:00
|
|
|
|
settingsLoaded = true;
|
|
|
|
|
|
2014-06-08 07:29:26 +12:00
|
|
|
|
UpdateUI();
|
2014-05-09 15:14:53 +12:00
|
|
|
|
}
|
|
|
|
|
|
2015-06-26 02:06:26 +12:00
|
|
|
|
private void RefreshSourcesAsync(bool selectDevices = false)
|
2014-05-13 18:57:09 +12:00
|
|
|
|
{
|
2014-05-13 20:44:35 +12:00
|
|
|
|
btnRefreshSources.Enabled = false;
|
2014-05-13 18:57:09 +12:00
|
|
|
|
DirectShowDevices devices = null;
|
2014-05-22 13:48:27 +12:00
|
|
|
|
|
2014-05-24 03:39:14 +12:00
|
|
|
|
TaskEx.Run(() =>
|
2014-05-13 18:57:09 +12:00
|
|
|
|
{
|
|
|
|
|
using (FFmpegHelper ffmpeg = new FFmpegHelper(Options))
|
|
|
|
|
{
|
|
|
|
|
devices = ffmpeg.GetDirectShowDevices();
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
() =>
|
|
|
|
|
{
|
|
|
|
|
cboVideoSource.Items.Clear();
|
2014-08-29 20:22:51 +12:00
|
|
|
|
cboVideoSource.Items.Add(FFmpegHelper.SourceNone);
|
|
|
|
|
cboVideoSource.Items.Add(FFmpegHelper.SourceGDIGrab);
|
2014-05-13 18:57:09 +12:00
|
|
|
|
cboAudioSource.Items.Clear();
|
2014-08-29 20:22:51 +12:00
|
|
|
|
cboAudioSource.Items.Add(FFmpegHelper.SourceNone);
|
2015-06-26 02:06:26 +12:00
|
|
|
|
|
2014-05-13 18:57:09 +12:00
|
|
|
|
if (devices != null)
|
|
|
|
|
{
|
|
|
|
|
cboVideoSource.Items.AddRange(devices.VideoDevices.ToArray());
|
|
|
|
|
cboAudioSource.Items.AddRange(devices.AudioDevices.ToArray());
|
|
|
|
|
}
|
2015-06-26 00:42:41 +12:00
|
|
|
|
|
2015-06-26 02:06:26 +12:00
|
|
|
|
if (selectDevices && cboVideoSource.Items.Contains(FFmpegHelper.SourceVideoDevice))
|
2015-06-26 00:42:41 +12:00
|
|
|
|
{
|
|
|
|
|
Options.FFmpeg.VideoSource = FFmpegHelper.SourceVideoDevice;
|
|
|
|
|
}
|
|
|
|
|
|
2014-05-13 20:44:35 +12:00
|
|
|
|
cboVideoSource.Text = Options.FFmpeg.VideoSource;
|
2015-06-26 00:42:41 +12:00
|
|
|
|
|
2015-06-26 02:06:26 +12:00
|
|
|
|
if (selectDevices && cboAudioSource.Items.Contains(FFmpegHelper.SourceAudioDevice))
|
2015-06-26 00:42:41 +12:00
|
|
|
|
{
|
|
|
|
|
Options.FFmpeg.AudioSource = FFmpegHelper.SourceAudioDevice;
|
|
|
|
|
}
|
|
|
|
|
|
2014-05-13 20:44:35 +12:00
|
|
|
|
cboAudioSource.Text = Options.FFmpeg.AudioSource;
|
2015-06-26 00:42:41 +12:00
|
|
|
|
|
2014-05-13 20:44:35 +12:00
|
|
|
|
btnRefreshSources.Enabled = true;
|
2014-05-13 18:57:09 +12:00
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2014-07-03 20:33:24 +12:00
|
|
|
|
private void UpdateUI()
|
2014-05-12 20:40:56 +12:00
|
|
|
|
{
|
2014-07-03 20:33:24 +12:00
|
|
|
|
if (settingsLoaded)
|
2014-05-12 11:19:38 +12:00
|
|
|
|
{
|
2014-10-18 00:08:33 +13:00
|
|
|
|
lblAACQuality.Text = string.Format(Resources.FFmpegOptionsForm_UpdateUI_Bitrate___0_k, Options.FFmpeg.AAC_bitrate);
|
|
|
|
|
lblVorbisQuality.Text = Resources.FFmpegOptionsForm_UpdateUI_Quality_ + " " + Options.FFmpeg.Vorbis_qscale;
|
|
|
|
|
lblMP3Quality.Text = Resources.FFmpegOptionsForm_UpdateUI_Quality_ + " " + Options.FFmpeg.MP3_qscale;
|
2014-05-09 23:45:10 +12:00
|
|
|
|
|
2015-10-21 11:18:28 +13:00
|
|
|
|
bool isValidAudioCodec = true;
|
|
|
|
|
FFmpegVideoCodec videoCodec = (FFmpegVideoCodec)cboVideoCodec.SelectedIndex;
|
|
|
|
|
|
|
|
|
|
if (videoCodec == FFmpegVideoCodec.libvpx)
|
|
|
|
|
{
|
|
|
|
|
FFmpegAudioCodec audioCodec = (FFmpegAudioCodec)cboAudioCodec.SelectedIndex;
|
|
|
|
|
|
|
|
|
|
if (audioCodec != FFmpegAudioCodec.libvorbis)
|
|
|
|
|
{
|
|
|
|
|
isValidAudioCodec = false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2015-10-29 20:03:16 +13:00
|
|
|
|
pbAudioCodecWarning.Visible = !isValidAudioCodec;
|
|
|
|
|
pbx264PresetWarning.Visible = (FFmpegPreset)cbx264Preset.SelectedIndex > FFmpegPreset.fast;
|
2015-10-21 11:18:28 +13:00
|
|
|
|
|
2014-07-03 20:33:24 +12:00
|
|
|
|
if (!Options.FFmpeg.UseCustomCommands)
|
|
|
|
|
{
|
|
|
|
|
txtCommandLinePreview.Text = Options.GetFFmpegArgs();
|
|
|
|
|
}
|
2014-05-14 23:18:18 +12:00
|
|
|
|
|
2016-02-13 11:51:56 +13:00
|
|
|
|
UpdateFFmpegPathUI();
|
|
|
|
|
}
|
2015-09-13 08:32:51 +12:00
|
|
|
|
}
|
|
|
|
|
|
2016-02-13 11:51:56 +13:00
|
|
|
|
private void UpdateFFmpegPathUI()
|
2015-09-13 08:32:51 +12:00
|
|
|
|
{
|
2015-09-16 11:37:42 +12:00
|
|
|
|
#if !STEAM
|
2016-01-08 07:30:35 +13:00
|
|
|
|
Color backColor = Color.FromArgb(255, 200, 200);
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
if (File.Exists(Options.FFmpeg.FFmpegPath))
|
|
|
|
|
{
|
|
|
|
|
backColor = Color.FromArgb(200, 255, 200);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch { }
|
|
|
|
|
|
|
|
|
|
txtFFmpegPath.BackColor = backColor;
|
2015-09-16 11:37:42 +12:00
|
|
|
|
#endif
|
2015-09-13 08:32:51 +12:00
|
|
|
|
}
|
|
|
|
|
|
2016-02-13 11:51:56 +13:00
|
|
|
|
private void cbOverrideFFmpegPath_CheckedChanged(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
#if STEAM
|
|
|
|
|
Options.FFmpeg.OverrideCLIPath = cbOverrideFFmpegPath.Checked;
|
|
|
|
|
gbFFmpegExe.Enabled = Options.FFmpeg.OverrideCLIPath;
|
|
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void txtFFmpegPath_TextChanged(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
Options.FFmpeg.CLIPath = txtFFmpegPath.Text;
|
|
|
|
|
UpdateFFmpegPathUI();
|
|
|
|
|
}
|
|
|
|
|
|
2015-09-13 08:32:51 +12:00
|
|
|
|
private void buttonFFmpegBrowse_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
2016-02-13 11:51:56 +13:00
|
|
|
|
if (Helpers.BrowseFile(Resources.FFmpegOptionsForm_buttonFFmpegBrowse_Click_Browse_for_ffmpeg_exe, txtFFmpegPath, Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles), true))
|
2015-09-13 08:32:51 +12:00
|
|
|
|
{
|
|
|
|
|
RefreshSourcesAsync();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2014-05-13 20:44:35 +12:00
|
|
|
|
private void btnRefreshSources_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
RefreshSourcesAsync();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void cboVideoSource_SelectedIndexChanged(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
Options.FFmpeg.VideoSource = cboVideoSource.Text;
|
2014-06-04 11:18:41 +12:00
|
|
|
|
UpdateUI();
|
2014-05-13 20:44:35 +12:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void cboAudioSource_SelectedIndexChanged(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
Options.FFmpeg.AudioSource = cboAudioSource.Text;
|
2014-06-04 11:18:41 +12:00
|
|
|
|
UpdateUI();
|
2014-05-13 20:44:35 +12:00
|
|
|
|
}
|
|
|
|
|
|
2015-06-22 13:26:21 +12:00
|
|
|
|
private void btnInstallHelperDevices_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
2015-06-26 02:06:26 +12:00
|
|
|
|
string filepath = Helpers.GetAbsolutePath(FFmpegHelper.DeviceSetupPath);
|
2015-06-26 00:42:41 +12:00
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrEmpty(filepath) && File.Exists(filepath))
|
|
|
|
|
{
|
|
|
|
|
TaskEx.Run(() =>
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
Process process = Process.Start(filepath);
|
|
|
|
|
|
2015-06-26 02:06:26 +12:00
|
|
|
|
if (process.WaitForExit(1000 * 60 * 5) && process.ExitCode == 0)
|
2015-06-26 00:42:41 +12:00
|
|
|
|
{
|
|
|
|
|
this.InvokeSafe(() =>
|
|
|
|
|
{
|
2015-06-26 02:06:26 +12:00
|
|
|
|
RefreshSourcesAsync(true);
|
2015-06-26 00:42:41 +12:00
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch { }
|
|
|
|
|
});
|
|
|
|
|
}
|
2015-07-04 13:33:13 +12:00
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
MessageBox.Show("File not exists: \"" + filepath + "\"", "ShareX", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
|
|
|
}
|
2015-06-22 13:26:21 +12:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void btnHelperDevicesHelp_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
URLHelpers.OpenURL("https://github.com/rdp/screen-capture-recorder-to-video-windows-free");
|
|
|
|
|
}
|
|
|
|
|
|
2014-05-13 20:44:35 +12:00
|
|
|
|
private void cboVideoCodec_SelectedIndexChanged(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
Options.FFmpeg.VideoCodec = (FFmpegVideoCodec)cboVideoCodec.SelectedIndex;
|
2014-07-03 20:33:24 +12:00
|
|
|
|
|
|
|
|
|
if (cboVideoCodec.SelectedIndex >= 0)
|
|
|
|
|
{
|
2015-06-02 00:35:13 +12:00
|
|
|
|
switch (Options.FFmpeg.VideoCodec)
|
|
|
|
|
{
|
|
|
|
|
default:
|
|
|
|
|
case FFmpegVideoCodec.libx264:
|
|
|
|
|
case FFmpegVideoCodec.libx265:
|
|
|
|
|
tcFFmpegVideoCodecs.SelectedIndex = 0;
|
|
|
|
|
break;
|
|
|
|
|
case FFmpegVideoCodec.libvpx:
|
|
|
|
|
tcFFmpegVideoCodecs.SelectedIndex = 1;
|
|
|
|
|
break;
|
|
|
|
|
case FFmpegVideoCodec.libxvid:
|
|
|
|
|
tcFFmpegVideoCodecs.SelectedIndex = 2;
|
|
|
|
|
break;
|
2016-12-03 05:35:34 +13:00
|
|
|
|
case FFmpegVideoCodec.h264_nvenc:
|
|
|
|
|
case FFmpegVideoCodec.hevc_nvenc:
|
2015-06-09 10:55:45 +12:00
|
|
|
|
tcFFmpegVideoCodecs.SelectedIndex = 3;
|
|
|
|
|
break;
|
2016-12-03 05:35:34 +13:00
|
|
|
|
case FFmpegVideoCodec.gif:
|
|
|
|
|
tcFFmpegVideoCodecs.SelectedIndex = 4;
|
|
|
|
|
break;
|
2015-06-02 00:35:13 +12:00
|
|
|
|
}
|
2014-07-03 20:33:24 +12:00
|
|
|
|
}
|
|
|
|
|
|
2014-06-04 11:18:41 +12:00
|
|
|
|
UpdateUI();
|
2014-05-13 20:44:35 +12:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void cboAudioCodec_SelectedIndexChanged(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
Options.FFmpeg.AudioCodec = (FFmpegAudioCodec)cboAudioCodec.SelectedIndex;
|
2014-07-03 20:33:24 +12:00
|
|
|
|
|
|
|
|
|
if (cboAudioCodec.SelectedIndex >= 0)
|
|
|
|
|
{
|
2015-06-02 00:35:13 +12:00
|
|
|
|
switch (Options.FFmpeg.AudioCodec)
|
|
|
|
|
{
|
|
|
|
|
default:
|
|
|
|
|
case FFmpegAudioCodec.libvoaacenc:
|
|
|
|
|
tcFFmpegAudioCodecs.SelectedIndex = 0;
|
|
|
|
|
break;
|
|
|
|
|
case FFmpegAudioCodec.libvorbis:
|
|
|
|
|
tcFFmpegAudioCodecs.SelectedIndex = 1;
|
|
|
|
|
break;
|
|
|
|
|
case FFmpegAudioCodec.libmp3lame:
|
|
|
|
|
tcFFmpegAudioCodecs.SelectedIndex = 2;
|
|
|
|
|
break;
|
|
|
|
|
}
|
2014-07-03 20:33:24 +12:00
|
|
|
|
}
|
|
|
|
|
|
2014-06-04 11:18:41 +12:00
|
|
|
|
UpdateUI();
|
2014-05-13 20:44:35 +12:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void nudx264CRF_ValueChanged(object sender, EventArgs e)
|
|
|
|
|
{
|
2014-05-13 23:50:31 +12:00
|
|
|
|
Options.FFmpeg.x264_CRF = (int)nudx264CRF.Value;
|
2014-06-04 11:18:41 +12:00
|
|
|
|
UpdateUI();
|
2014-05-13 20:44:35 +12:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void cbPreset_SelectedIndexChanged(object sender, EventArgs e)
|
|
|
|
|
{
|
2015-06-09 06:19:30 +12:00
|
|
|
|
Options.FFmpeg.x264_Preset = (FFmpegPreset)cbx264Preset.SelectedIndex;
|
2014-06-04 11:18:41 +12:00
|
|
|
|
UpdateUI();
|
2014-05-13 20:44:35 +12:00
|
|
|
|
}
|
|
|
|
|
|
2015-05-16 12:21:59 +12:00
|
|
|
|
private void nudVP8Bitrate_ValueChanged(object sender, EventArgs e)
|
2014-05-13 20:44:35 +12:00
|
|
|
|
{
|
2015-05-16 12:21:59 +12:00
|
|
|
|
Options.FFmpeg.VPx_bitrate = (int)nudVP8Bitrate.Value;
|
2014-06-04 11:18:41 +12:00
|
|
|
|
UpdateUI();
|
2014-05-13 20:44:35 +12:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void nudQscale_ValueChanged(object sender, EventArgs e)
|
|
|
|
|
{
|
2015-06-09 06:19:30 +12:00
|
|
|
|
Options.FFmpeg.XviD_qscale = (int)nudXvidQscale.Value;
|
|
|
|
|
UpdateUI();
|
|
|
|
|
}
|
|
|
|
|
|
2016-12-03 05:35:34 +13:00
|
|
|
|
private void cbNVENCPreset_SelectedIndexChanged(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
Options.FFmpeg.NVENC_preset = (FFmpegNVENCPreset)cbNVENCPreset.SelectedIndex;
|
|
|
|
|
UpdateUI();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void nudNVENCBitrate_ValueChanged(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
Options.FFmpeg.NVENC_bitrate = (int)nudNVENCBitrate.Value;
|
|
|
|
|
UpdateUI();
|
|
|
|
|
}
|
|
|
|
|
|
2015-06-09 06:19:30 +12:00
|
|
|
|
private void cbGIFStatsMode_SelectedIndexChanged(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
Options.FFmpeg.GIFStatsMode = (FFmpegPaletteGenStatsMode)cbGIFStatsMode.SelectedIndex;
|
|
|
|
|
UpdateUI();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void cbGIFDither_SelectedIndexChanged(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
Options.FFmpeg.GIFDither = (FFmpegPaletteUseDither)cbGIFDither.SelectedIndex;
|
2014-06-04 11:18:41 +12:00
|
|
|
|
UpdateUI();
|
2014-05-13 20:44:35 +12:00
|
|
|
|
}
|
|
|
|
|
|
2014-07-03 20:33:24 +12:00
|
|
|
|
private void tbAACBitrate_ValueChanged(object sender, EventArgs e)
|
2014-05-15 18:13:49 +12:00
|
|
|
|
{
|
|
|
|
|
Options.FFmpeg.AAC_bitrate = tbAACBitrate.Value * 32;
|
|
|
|
|
UpdateUI();
|
|
|
|
|
}
|
|
|
|
|
|
2014-07-03 20:33:24 +12:00
|
|
|
|
private void tbVorbis_qscale_ValueChanged(object sender, EventArgs e)
|
2014-05-15 18:13:49 +12:00
|
|
|
|
{
|
|
|
|
|
Options.FFmpeg.Vorbis_qscale = tbVorbis_qscale.Value;
|
|
|
|
|
UpdateUI();
|
|
|
|
|
}
|
|
|
|
|
|
2014-07-03 20:33:24 +12:00
|
|
|
|
private void tbMP3_qscale_ValueChanged(object sender, EventArgs e)
|
2014-05-15 18:13:49 +12:00
|
|
|
|
{
|
2014-07-03 20:33:24 +12:00
|
|
|
|
Options.FFmpeg.MP3_qscale = FFmpegHelper.libmp3lame_qscale_end - tbMP3_qscale.Value;
|
2014-05-15 18:13:49 +12:00
|
|
|
|
UpdateUI();
|
|
|
|
|
}
|
|
|
|
|
|
2014-05-13 20:44:35 +12:00
|
|
|
|
private void tbUserArgs_TextChanged(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
Options.FFmpeg.UserArgs = tbUserArgs.Text;
|
2014-06-04 11:18:41 +12:00
|
|
|
|
UpdateUI();
|
2014-05-13 20:44:35 +12:00
|
|
|
|
}
|
|
|
|
|
|
2014-05-09 23:45:10 +12:00
|
|
|
|
private void buttonFFmpegHelp_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
2014-07-03 20:33:24 +12:00
|
|
|
|
URLHelpers.OpenURL("https://github.com/ShareX/ShareX/wiki/FFmpeg-options#additional-commands");
|
2014-05-09 20:12:44 +12:00
|
|
|
|
}
|
2014-05-10 12:23:47 +12:00
|
|
|
|
|
|
|
|
|
private void btnDownload_Click(object sender, EventArgs e)
|
2014-05-10 13:52:09 +12:00
|
|
|
|
{
|
2014-12-09 05:15:18 +13:00
|
|
|
|
FFmpegDownloader.DownloadFFmpeg(true, DownloaderForm_InstallRequested);
|
2014-05-10 13:52:09 +12:00
|
|
|
|
}
|
|
|
|
|
|
2014-05-12 10:58:10 +12:00
|
|
|
|
private void DownloaderForm_InstallRequested(string filePath)
|
2014-05-10 12:23:47 +12:00
|
|
|
|
{
|
2014-05-12 11:19:38 +12:00
|
|
|
|
string extractPath = DefaultToolsPath ?? "ffmpeg.exe";
|
2014-12-09 05:15:18 +13:00
|
|
|
|
bool result = FFmpegDownloader.ExtractFFmpeg(filePath, extractPath);
|
2014-05-10 12:23:47 +12:00
|
|
|
|
|
|
|
|
|
if (result)
|
|
|
|
|
{
|
2014-05-13 18:57:09 +12:00
|
|
|
|
this.InvokeSafe(() =>
|
|
|
|
|
{
|
2016-02-13 11:51:56 +13:00
|
|
|
|
txtFFmpegPath.Text = Helpers.GetVariableFolderPath(extractPath);
|
2014-05-13 20:44:35 +12:00
|
|
|
|
RefreshSourcesAsync();
|
2014-05-15 18:13:49 +12:00
|
|
|
|
UpdateUI();
|
2014-05-13 18:57:09 +12:00
|
|
|
|
});
|
2014-06-05 02:08:07 +12:00
|
|
|
|
|
2014-10-18 01:19:28 +13:00
|
|
|
|
MessageBox.Show(Resources.FFmpegOptionsForm_DownloaderForm_InstallRequested_Successfully_downloaded_FFmpeg_, "ShareX", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
2014-05-10 12:23:47 +12:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2014-10-18 01:19:28 +13:00
|
|
|
|
MessageBox.Show(Resources.FFmpegOptionsForm_DownloaderForm_InstallRequested_Download_of_FFmpeg_failed_, "ShareX", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
2014-05-10 12:23:47 +12:00
|
|
|
|
}
|
|
|
|
|
}
|
2014-05-12 22:56:37 +12:00
|
|
|
|
|
|
|
|
|
private void btnTest_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
2015-09-13 08:32:51 +12:00
|
|
|
|
if (File.Exists(Options.FFmpeg.FFmpegPath))
|
2014-05-12 22:56:37 +12:00
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
using (Process process = new Process())
|
|
|
|
|
{
|
2014-05-12 23:15:17 +12:00
|
|
|
|
ProcessStartInfo psi = new ProcessStartInfo("cmd.exe");
|
2015-09-16 08:11:43 +12:00
|
|
|
|
psi.Arguments = $"/k {Path.GetFileName(Options.FFmpeg.FFmpegPath)} {Options.GetFFmpegCommands()}";
|
2015-09-13 08:32:51 +12:00
|
|
|
|
psi.WorkingDirectory = Path.GetDirectoryName(Options.FFmpeg.FFmpegPath);
|
2014-05-12 22:56:37 +12:00
|
|
|
|
|
|
|
|
|
process.StartInfo = psi;
|
|
|
|
|
process.Start();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
DebugHelper.WriteException(ex);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void btnCopyPreview_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
2015-09-16 08:11:43 +12:00
|
|
|
|
ClipboardHelpers.CopyText($"{Path.GetFileName(Options.FFmpeg.FFmpegPath)} {Options.GetFFmpegCommands()}");
|
2014-05-13 18:57:09 +12:00
|
|
|
|
}
|
2014-05-30 19:41:32 +12:00
|
|
|
|
|
2014-06-04 11:18:41 +12:00
|
|
|
|
private void cbCustomCommands_CheckedChanged(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
Options.FFmpeg.UseCustomCommands = cbCustomCommands.Checked;
|
|
|
|
|
txtCommandLinePreview.ReadOnly = !Options.FFmpeg.UseCustomCommands;
|
|
|
|
|
|
2014-07-19 22:14:53 +12:00
|
|
|
|
if (settingsLoaded)
|
2014-06-04 23:55:25 +12:00
|
|
|
|
{
|
2014-07-19 22:14:53 +12:00
|
|
|
|
if (Options.FFmpeg.UseCustomCommands)
|
|
|
|
|
{
|
|
|
|
|
txtCommandLinePreview.Text = Options.GetFFmpegArgs(true);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
txtCommandLinePreview.Text = Options.GetFFmpegArgs();
|
|
|
|
|
}
|
2014-06-04 23:55:25 +12:00
|
|
|
|
}
|
2014-06-04 11:18:41 +12:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void txtCommandLinePreview_TextChanged(object sender, EventArgs e)
|
|
|
|
|
{
|
2014-06-04 23:55:25 +12:00
|
|
|
|
Options.FFmpeg.CustomCommands = txtCommandLinePreview.Text;
|
2014-06-04 11:18:41 +12:00
|
|
|
|
}
|
2014-06-08 08:19:31 +12:00
|
|
|
|
|
|
|
|
|
private void btnHelp_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
2014-07-03 06:19:51 +12:00
|
|
|
|
URLHelpers.OpenURL("https://github.com/ShareX/ShareX/wiki/FFmpeg-options");
|
2014-06-08 08:19:31 +12:00
|
|
|
|
}
|
2014-06-08 16:07:55 +12:00
|
|
|
|
|
|
|
|
|
private object eiFFmpeg_ExportRequested()
|
|
|
|
|
{
|
|
|
|
|
return Options.FFmpeg;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void eiFFmpeg_ImportRequested(object obj)
|
|
|
|
|
{
|
|
|
|
|
FFmpegOptions ffmpegOptions = obj as FFmpegOptions;
|
|
|
|
|
|
|
|
|
|
if (ffmpegOptions != null)
|
|
|
|
|
{
|
|
|
|
|
string tempFFmpegPath = Options.FFmpeg.CLIPath;
|
|
|
|
|
Options.FFmpeg = ffmpegOptions;
|
|
|
|
|
Options.FFmpeg.CLIPath = tempFFmpegPath;
|
|
|
|
|
SettingsLoad();
|
|
|
|
|
}
|
|
|
|
|
}
|
2014-05-09 15:14:53 +12:00
|
|
|
|
}
|
|
|
|
|
}
|