Added FFmpeg override path setting for Steam build so it can use built in FFmpeg by default

This commit is contained in:
Jaex 2015-09-12 23:32:51 +03:00
parent 442df9c1c0
commit 06bcc15785
9 changed files with 764 additions and 364 deletions

4
.gitignore vendored
View file

@ -198,4 +198,6 @@ FakesAssemblies/
# Additional
InnoSetup/Output/
ShareX/GitHash.txt
ShareX.UploadersLib/APIKeys/APIKeysLocal.cs
ShareX.UploadersLib/APIKeys/APIKeysLocal.cs
Lib/ffmpeg.exe
Lib/ffmpeg-x64.exe

View file

@ -80,7 +80,7 @@ private void FFmpegHelper_DataReceived(object sender, DataReceivedEventArgs e)
public bool Record()
{
recordingStarted = false;
return Run(Options.FFmpeg.CLIPath, Options.GetFFmpegCommands());
return Run(Options.FFmpeg.FFmpegPath, Options.GetFFmpegCommands());
}
protected void OnRecordingStarted()
@ -95,17 +95,17 @@ public bool EncodeGIF(string input, string output)
{
bool result;
string palettePath = Path.Combine(Path.GetDirectoryName(Options.FFmpeg.CLIPath), "palette.png");
string palettePath = Path.Combine(Path.GetDirectoryName(Options.FFmpeg.FFmpegPath), "palette.png");
try
{
// https://ffmpeg.org/ffmpeg-filters.html#palettegen-1
result = Run(Options.FFmpeg.CLIPath, string.Format("-y -i \"{0}\" -vf \"palettegen=stats_mode={2}\" \"{1}\"", input, palettePath, Options.FFmpeg.GIFStatsMode));
result = Run(Options.FFmpeg.FFmpegPath, string.Format("-y -i \"{0}\" -vf \"palettegen=stats_mode={2}\" \"{1}\"", input, palettePath, Options.FFmpeg.GIFStatsMode));
if (result)
{
// https://ffmpeg.org/ffmpeg-filters.html#paletteuse
result = Run(Options.FFmpeg.CLIPath, string.Format("-y -i \"{0}\" -i \"{1}\" -lavfi \"paletteuse=dither={3}\" \"{2}\"", input, palettePath, output, Options.FFmpeg.GIFDither));
result = Run(Options.FFmpeg.FFmpegPath, string.Format("-y -i \"{0}\" -i \"{1}\" -lavfi \"paletteuse=dither={3}\" \"{2}\"", input, palettePath, output, Options.FFmpeg.GIFDither));
}
}
finally
@ -134,10 +134,10 @@ public DirectShowDevices GetDirectShowDevices()
{
DirectShowDevices devices = new DirectShowDevices();
if (File.Exists(Options.FFmpeg.CLIPath))
if (File.Exists(Options.FFmpeg.FFmpegPath))
{
string arg = "-list_devices true -f dshow -i dummy";
Open(Options.FFmpeg.CLIPath, arg);
Open(Options.FFmpeg.FFmpegPath, arg);
string output = Output.ToString();
string[] lines = output.Lines();
bool isVideo = true;

View file

@ -23,6 +23,7 @@
#endregion License Information (GPL v3)
using ShareX.HelpersLib;
using System;
namespace ShareX.ScreenCaptureLib
@ -30,11 +31,12 @@ namespace ShareX.ScreenCaptureLib
public class FFmpegOptions
{
// General
public bool OverrideCLIPath { get; set; }
public string CLIPath { get; set; }
public string VideoSource { get; set; }
public string AudioSource { get; set; }
public FFmpegVideoCodec VideoCodec { get; set; }
public FFmpegAudioCodec AudioCodec { get; set; }
public string CLIPath { get; set; }
public string UserArgs { get; set; }
public bool UseCustomCommands { get; set; }
public string CustomCommands { get; set; }
@ -53,6 +55,28 @@ public class FFmpegOptions
public int Vorbis_qscale { get; set; }
public int MP3_qscale { get; set; }
public string FFmpegPath
{
get
{
#if STEAM
if (!OverrideCLIPath)
{
if (NativeMethods.Is64Bit())
{
return Helpers.GetAbsolutePath("ffmpeg-x64.exe");
}
else
{
return Helpers.GetAbsolutePath("ffmpeg.exe");
}
}
#endif
return CLIPath;
}
}
public string Extension
{
get
@ -116,11 +140,11 @@ public bool IsAudioSourceSelected
public FFmpegOptions()
{
// General
OverrideCLIPath = false;
VideoSource = FFmpegHelper.SourceGDIGrab;
AudioSource = FFmpegHelper.SourceNone;
VideoCodec = FFmpegVideoCodec.libx264;
AudioCodec = FFmpegAudioCodec.libvoaacenc;
CLIPath = "ffmpeg.exe";
UserArgs = "";
ShowError = true;

View file

@ -45,6 +45,7 @@ private void InitializeComponent()
this.lblx264Preset = new System.Windows.Forms.Label();
this.lblXvidQscale = new System.Windows.Forms.Label();
this.gbFFmpegExe = new System.Windows.Forms.GroupBox();
this.cbOverrideFFmpegPath = new System.Windows.Forms.CheckBox();
this.btnDownload = new System.Windows.Forms.Button();
this.btnFFmpegBrowse = new System.Windows.Forms.Button();
this.txtFFmpegPath = new System.Windows.Forms.TextBox();
@ -259,6 +260,13 @@ private void InitializeComponent()
this.gbFFmpegExe.Name = "gbFFmpegExe";
this.gbFFmpegExe.TabStop = false;
//
// cbOverrideFFmpegPath
//
resources.ApplyResources(this.cbOverrideFFmpegPath, "cbOverrideFFmpegPath");
this.cbOverrideFFmpegPath.Name = "cbOverrideFFmpegPath";
this.cbOverrideFFmpegPath.UseVisualStyleBackColor = true;
this.cbOverrideFFmpegPath.CheckedChanged += new System.EventHandler(this.cbOverrideFFmpegPath_CheckedChanged);
//
// btnDownload
//
resources.ApplyResources(this.btnDownload, "btnDownload");
@ -277,7 +285,7 @@ private void InitializeComponent()
//
resources.ApplyResources(this.txtFFmpegPath, "txtFFmpegPath");
this.txtFFmpegPath.Name = "txtFFmpegPath";
this.txtFFmpegPath.TextChanged += new System.EventHandler(this.tbFFmpegPath_TextChanged);
this.txtFFmpegPath.TextChanged += new System.EventHandler(this.txtFFmpegPath_TextChanged);
//
// gbCommandLinePreview
//
@ -590,6 +598,7 @@ private void InitializeComponent()
resources.ApplyResources(this, "$this");
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.BackColor = System.Drawing.Color.White;
this.Controls.Add(this.cbOverrideFFmpegPath);
this.Controls.Add(this.eiFFmpeg);
this.Controls.Add(this.btnHelp);
this.Controls.Add(this.gbCodecs);
@ -637,6 +646,7 @@ private void InitializeComponent()
this.gbCodecs.ResumeLayout(false);
this.gbCodecs.PerformLayout();
this.ResumeLayout(false);
this.PerformLayout();
}
@ -699,5 +709,6 @@ private void InitializeComponent()
private System.Windows.Forms.Button btnHelperDevicesHelp;
private System.Windows.Forms.Label lblHelperDevices;
private System.Windows.Forms.Button btnInstallHelperDevices;
private System.Windows.Forms.CheckBox cbOverrideFFmpegPath;
}
}

View file

@ -60,20 +60,22 @@ private void SettingsLoad()
settingsLoaded = false;
// General
#if STEAM
cbOverrideFFmpegPath.Checked = Options.FFmpeg.OverrideCLIPath;
gbFFmpegExe.Enabled = Options.FFmpeg.OverrideCLIPath;
#else
cbOverrideFFmpegPath.Visible = false;
#endif
txtFFmpegPath.Text = Options.FFmpeg.CLIPath;
txtFFmpegPath.SelectionStart = txtFFmpegPath.TextLength;
RefreshSourcesAsync();
cboVideoCodec.SelectedIndex = (int)Options.FFmpeg.VideoCodec;
cboAudioCodec.SelectedIndex = (int)Options.FFmpeg.AudioCodec;
string cli = "ffmpeg.exe";
if (string.IsNullOrEmpty(Options.FFmpeg.CLIPath) && File.Exists(cli))
{
Options.FFmpeg.CLIPath = cli;
}
txtFFmpegPath.Text = Options.FFmpeg.CLIPath;
txtFFmpegPath.SelectionStart = txtFFmpegPath.TextLength;
tbUserArgs.Text = Options.FFmpeg.UserArgs;
// x264
@ -170,6 +172,27 @@ private void UpdateUI()
}
}
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;
}
private void buttonFFmpegBrowse_Click(object sender, EventArgs e)
{
if (Helpers.BrowseFile(Resources.FFmpegOptionsForm_buttonFFmpegBrowse_Click_Browse_for_ffmpeg_exe, txtFFmpegPath, Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles)))
{
RefreshSourcesAsync();
}
}
private void btnRefreshSources_Click(object sender, EventArgs e)
{
RefreshSourcesAsync();
@ -327,20 +350,6 @@ private void tbMP3_qscale_ValueChanged(object sender, EventArgs e)
UpdateUI();
}
private void tbFFmpegPath_TextChanged(object sender, EventArgs e)
{
Options.FFmpeg.CLIPath = txtFFmpegPath.Text;
txtFFmpegPath.BackColor = File.Exists(txtFFmpegPath.Text) ? Color.FromArgb(200, 255, 200) : Color.FromArgb(255, 200, 200);
}
private void buttonFFmpegBrowse_Click(object sender, EventArgs e)
{
if (Helpers.BrowseFile(Resources.FFmpegOptionsForm_buttonFFmpegBrowse_Click_Browse_for_ffmpeg_exe, txtFFmpegPath, Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles)))
{
RefreshSourcesAsync();
}
}
private void tbUserArgs_TextChanged(object sender, EventArgs e)
{
Options.FFmpeg.UserArgs = tbUserArgs.Text;
@ -381,7 +390,7 @@ private void DownloaderForm_InstallRequested(string filePath)
private void btnTest_Click(object sender, EventArgs e)
{
if (File.Exists(Options.FFmpeg.CLIPath))
if (File.Exists(Options.FFmpeg.FFmpegPath))
{
try
{
@ -389,7 +398,7 @@ private void btnTest_Click(object sender, EventArgs e)
{
ProcessStartInfo psi = new ProcessStartInfo("cmd.exe");
psi.Arguments = "/k ffmpeg " + Options.GetFFmpegCommands();
psi.WorkingDirectory = Path.GetDirectoryName(Options.FFmpeg.CLIPath);
psi.WorkingDirectory = Path.GetDirectoryName(Options.FFmpeg.FFmpegPath);
process.StartInfo = psi;
process.Start();

File diff suppressed because it is too large Load diff

View file

@ -33,7 +33,7 @@
<DebugType>none</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<DefineConstants>TRACE;RELEASE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<AllowUnsafeBlocks>false</AllowUnsafeBlocks>
@ -43,7 +43,7 @@
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Steam|AnyCPU'">
<OutputPath>bin\Steam\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<DefineConstants>TRACE;STEAM</DefineConstants>
<Optimize>true</Optimize>
<PlatformTarget>AnyCPU</PlatformTarget>
<GenerateSerializationAssemblies>Off</GenerateSerializationAssemblies>

View file

@ -157,6 +157,13 @@ private static void CreatePortable(string destination)
CopyFiles(Path.Combine(ReleaseDirectory, language), "*.resources.dll", Path.Combine(destination, "Languages", language));
}
if (Setup == SetupType.Steam)
{
// These git ignored
CopyFile(Path.Combine(parentDir, "Lib", "ffmpeg.exe"), destination);
CopyFile(Path.Combine(parentDir, "Lib", "ffmpeg-x64.exe"), destination);
}
CopyFile(Path.Combine(outputDir, "Recorder-devices-setup.exe"), destination);
CopyFile(Path.Combine(parentDir, @"..\ShareX_Chrome\ShareX_Chrome\bin\Release\ShareX_Chrome.exe"), destination);

View file

@ -624,7 +624,7 @@ public static void OpenVideoThumbnailer(TaskSettings taskSettings = null)
}
taskSettings.ToolsSettings.VideoThumbnailOptions.DefaultOutputDirectory = taskSettings.CaptureFolder;
VideoThumbnailerForm thumbnailerForm = new VideoThumbnailerForm(taskSettings.CaptureSettings.FFmpegOptions.CLIPath, taskSettings.ToolsSettingsReference.VideoThumbnailOptions);
VideoThumbnailerForm thumbnailerForm = new VideoThumbnailerForm(taskSettings.CaptureSettings.FFmpegOptions.FFmpegPath, taskSettings.ToolsSettingsReference.VideoThumbnailOptions);
thumbnailerForm.ThumbnailsTaken += thumbnails =>
{
if (taskSettings.ToolsSettingsReference.VideoThumbnailOptions.UploadThumbnails)
@ -815,9 +815,9 @@ public static bool ToggleHotkeys()
public static bool CheckFFmpeg(TaskSettings taskSettings)
{
if (!File.Exists(taskSettings.CaptureSettings.FFmpegOptions.CLIPath))
if (!File.Exists(taskSettings.CaptureSettings.FFmpegOptions.FFmpegPath))
{
string ffmpegText = string.IsNullOrEmpty(taskSettings.CaptureSettings.FFmpegOptions.CLIPath) ? "ffmpeg.exe" : taskSettings.CaptureSettings.FFmpegOptions.CLIPath;
string ffmpegText = string.IsNullOrEmpty(taskSettings.CaptureSettings.FFmpegOptions.FFmpegPath) ? "ffmpeg.exe" : taskSettings.CaptureSettings.FFmpegOptions.FFmpegPath;
if (MessageBox.Show(string.Format(Resources.ScreenRecordForm_StartRecording_does_not_exist, ffmpegText),
"ShareX - " + Resources.ScreenRecordForm_StartRecording_Missing + " ffmpeg.exe", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes)
@ -826,6 +826,11 @@ public static bool CheckFFmpeg(TaskSettings taskSettings)
{
Program.DefaultTaskSettings.CaptureSettings.FFmpegOptions.CLIPath = taskSettings.TaskSettingsReference.CaptureSettings.FFmpegOptions.CLIPath =
taskSettings.CaptureSettings.FFmpegOptions.CLIPath = Path.Combine(Program.ToolsFolder, "ffmpeg.exe");
#if STEAM
Program.DefaultTaskSettings.CaptureSettings.FFmpegOptions.OverrideCLIPath = taskSettings.TaskSettingsReference.CaptureSettings.FFmpegOptions.OverrideCLIPath =
taskSettings.CaptureSettings.FFmpegOptions.OverrideCLIPath = true;
#endif
}
}
else