mirror of
https://github.com/ShareX/ShareX.git
synced 2024-09-29 17:02:05 +13:00
Added auto ffmpeg downloader/extractor
This commit is contained in:
parent
73c7108074
commit
10e254d80f
20 changed files with 264 additions and 79 deletions
Binary file not shown.
|
@ -243,7 +243,8 @@ public enum InstallType
|
|||
{
|
||||
Default,
|
||||
Silent,
|
||||
VerySilent
|
||||
VerySilent,
|
||||
Event
|
||||
}
|
||||
|
||||
public enum ReleaseChannelType
|
||||
|
|
|
@ -205,11 +205,11 @@
|
|||
<Compile Include="UnsafeBitmap.cs" />
|
||||
<Compile Include="UpdateChecker\GitHubUpdateChecker.cs" />
|
||||
<Compile Include="UpdateChecker\UpdateChecker.cs" />
|
||||
<Compile Include="UpdateChecker\UpdaterForm.cs">
|
||||
<Compile Include="UpdateChecker\DownloaderForm.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
<Compile Include="UpdateChecker\UpdaterForm.Designer.cs">
|
||||
<DependentUpon>UpdaterForm.cs</DependentUpon>
|
||||
<Compile Include="UpdateChecker\DownloaderForm.Designer.cs">
|
||||
<DependentUpon>DownloaderForm.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="FileDownloader.cs" />
|
||||
<Compile Include="UserControls\BlackStyle\MyButton.cs">
|
||||
|
@ -322,8 +322,8 @@
|
|||
<EmbeddedResource Include="Forms\MonitorTestForm.resx">
|
||||
<DependentUpon>MonitorTestForm.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="UpdateChecker\UpdaterForm.resx">
|
||||
<DependentUpon>UpdaterForm.cs</DependentUpon>
|
||||
<EmbeddedResource Include="UpdateChecker\DownloaderForm.resx">
|
||||
<DependentUpon>DownloaderForm.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="Printer\PrintForm.resx">
|
||||
<DependentUpon>PrintForm.cs</DependentUpon>
|
||||
|
|
|
@ -276,6 +276,10 @@ public static partial class NativeMethods
|
|||
[DllImport("kernel32.dll")]
|
||||
public static extern IntPtr GetModuleHandle(string lpModuleName);
|
||||
|
||||
[DllImport("kernel32.dll", CallingConvention = CallingConvention.Winapi)]
|
||||
[return: MarshalAs(UnmanagedType.Bool)]
|
||||
public static extern bool IsWow64Process([In] IntPtr hProcess, [Out] out bool lpSystemInfo);
|
||||
|
||||
#endregion kernel32.dll
|
||||
|
||||
#region gdi32.dll
|
||||
|
|
|
@ -330,9 +330,7 @@ public static bool SetTaskbarVisibility(bool visible)
|
|||
public static void TrimMemoryUse()
|
||||
{
|
||||
GC.Collect();
|
||||
#if !__MonoCS__
|
||||
GC.WaitForFullGCComplete();
|
||||
#endif
|
||||
SetProcessWorkingSetSize(Process.GetCurrentProcess().Handle, (IntPtr)(-1), (IntPtr)(-1));
|
||||
}
|
||||
|
||||
|
@ -447,5 +445,26 @@ public static string decode_mmioFOURCC(int code)
|
|||
}
|
||||
return new string(chs);
|
||||
}
|
||||
|
||||
public static bool Is64Bit()
|
||||
{
|
||||
if (IntPtr.Size == 8 || (IntPtr.Size == 4 && Is32BitProcessOn64BitProcessor()))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private static bool Is32BitProcessOn64BitProcessor()
|
||||
{
|
||||
bool retVal;
|
||||
|
||||
IsWow64Process(Process.GetCurrentProcess().Handle, out retVal);
|
||||
|
||||
return retVal;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,6 +1,6 @@
|
|||
namespace HelpersLib
|
||||
{
|
||||
partial class UpdaterForm
|
||||
partial class DownloaderForm
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
|
@ -135,7 +135,7 @@ private void InitializeComponent()
|
|||
this.pbProgress.TabIndex = 8;
|
||||
this.pbProgress.Value = 0;
|
||||
//
|
||||
// UpdaterForm
|
||||
// DownloaderForm
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
|
@ -152,9 +152,9 @@ private void InitializeComponent()
|
|||
this.DoubleBuffered = true;
|
||||
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
|
||||
this.MaximizeBox = false;
|
||||
this.Name = "UpdaterForm";
|
||||
this.Name = "DownloaderForm";
|
||||
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
|
||||
this.Text = "ShareX updater";
|
||||
this.Text = "ShareX downloader";
|
||||
this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.UpdaterForm_FormClosing);
|
||||
this.Shown += new System.EventHandler(this.DownloaderForm_Shown);
|
||||
this.Paint += new System.Windows.Forms.PaintEventHandler(this.UpdaterForm_Paint);
|
|
@ -35,8 +35,11 @@ You should have received a copy of the GNU General Public License
|
|||
|
||||
namespace HelpersLib
|
||||
{
|
||||
public partial class UpdaterForm : Form
|
||||
public partial class DownloaderForm : Form
|
||||
{
|
||||
public delegate void DownloaderInstallEventHandler(string filePath);
|
||||
public event DownloaderInstallEventHandler InstallRequested;
|
||||
|
||||
public string URL { get; set; }
|
||||
public string Filename { get; set; }
|
||||
public string SavePath { get; private set; }
|
||||
|
@ -52,7 +55,7 @@ public partial class UpdaterForm : Form
|
|||
private FileStream fileStream;
|
||||
private Rectangle fillRect;
|
||||
|
||||
private UpdaterForm()
|
||||
private DownloaderForm()
|
||||
{
|
||||
InitializeComponent();
|
||||
Icon = ShareXResources.Icon;
|
||||
|
@ -69,7 +72,7 @@ private UpdaterForm()
|
|||
AutoStartInstall = true;
|
||||
}
|
||||
|
||||
public UpdaterForm(UpdateChecker updateChecker)
|
||||
public DownloaderForm(UpdateChecker updateChecker)
|
||||
: this(updateChecker.UpdateInfo)
|
||||
{
|
||||
Proxy = updateChecker.Proxy;
|
||||
|
@ -80,11 +83,16 @@ public UpdaterForm(UpdateChecker updateChecker)
|
|||
}
|
||||
}
|
||||
|
||||
public UpdaterForm(UpdateInfo updateInfo)
|
||||
public DownloaderForm(UpdateInfo updateInfo)
|
||||
: this(updateInfo.DownloadURL, updateInfo.Filename)
|
||||
{
|
||||
}
|
||||
|
||||
public DownloaderForm(string url, string filename)
|
||||
: this()
|
||||
{
|
||||
URL = updateInfo.DownloadURL;
|
||||
Filename = updateInfo.Filename;
|
||||
URL = url;
|
||||
Filename = filename;
|
||||
lblFilename.Text = "Filename: " + Filename;
|
||||
}
|
||||
|
||||
|
@ -149,28 +157,43 @@ private void RunInstallerWithDelay(int delay = 1000)
|
|||
|
||||
private void RunInstaller()
|
||||
{
|
||||
try
|
||||
if (InstallType == InstallType.Event)
|
||||
{
|
||||
ProcessStartInfo psi = new ProcessStartInfo(SavePath);
|
||||
|
||||
if (InstallType == InstallType.Silent)
|
||||
{
|
||||
psi.Arguments = "/SILENT";
|
||||
}
|
||||
else if (InstallType == InstallType.VerySilent)
|
||||
{
|
||||
psi.Arguments = "/VERYSILENT";
|
||||
}
|
||||
|
||||
if (Helpers.IsDefaultInstallDir())
|
||||
{
|
||||
psi.Verb = "runas";
|
||||
}
|
||||
|
||||
psi.UseShellExecute = true;
|
||||
Process.Start(psi);
|
||||
OnInstallRequested();
|
||||
}
|
||||
else
|
||||
{
|
||||
try
|
||||
{
|
||||
ProcessStartInfo psi = new ProcessStartInfo(SavePath);
|
||||
|
||||
if (InstallType == InstallType.Silent)
|
||||
{
|
||||
psi.Arguments = "/SILENT";
|
||||
}
|
||||
else if (InstallType == InstallType.VerySilent)
|
||||
{
|
||||
psi.Arguments = "/VERYSILENT";
|
||||
}
|
||||
|
||||
if (Helpers.IsDefaultInstallDir())
|
||||
{
|
||||
psi.Verb = "runas";
|
||||
}
|
||||
|
||||
psi.UseShellExecute = true;
|
||||
Process.Start(psi);
|
||||
}
|
||||
catch { }
|
||||
}
|
||||
}
|
||||
|
||||
protected void OnInstallRequested()
|
||||
{
|
||||
if (InstallRequested != null)
|
||||
{
|
||||
InstallRequested(SavePath);
|
||||
}
|
||||
catch { }
|
||||
}
|
||||
|
||||
private void ChangeStatus(string status)
|
||||
|
@ -201,7 +224,7 @@ private void StartDownload()
|
|||
fileStream = new FileStream(SavePath, FileMode.Create, FileAccess.Write, FileShare.Read);
|
||||
fileDownloader = new FileDownloader(URL, fileStream, Proxy, AcceptHeader);
|
||||
fileDownloader.FileSizeReceived += (v1, v2) => ChangeProgress();
|
||||
fileDownloader.DownloadStarted += (v1, v2) => ChangeStatus("Download started.");
|
||||
fileDownloader.DownloadStarted += (v1, v2) => ChangeStatus("Downloading.");
|
||||
fileDownloader.ProgressChanged += (v1, v2) => ChangeProgress();
|
||||
fileDownloader.DownloadCompleted += fileDownloader_DownloadCompleted;
|
||||
fileDownloader.ExceptionThrowed += (v1, v2) => ChangeStatus(fileDownloader.LastException.Message);
|
|
@ -92,7 +92,7 @@ private void llblUpdateAvailable_LinkClicked(object sender, LinkLabelLinkClicked
|
|||
{
|
||||
if (updateChecker != null && updateChecker.UpdateInfo != null && updateChecker.UpdateInfo.Status == UpdateStatus.UpdateAvailable)
|
||||
{
|
||||
using (UpdaterForm updaterForm = new UpdaterForm(updateChecker))
|
||||
using (DownloaderForm updaterForm = new DownloaderForm(updateChecker))
|
||||
{
|
||||
updaterForm.ShowDialog();
|
||||
|
||||
|
|
BIN
Lib/7z-x64.dll
Normal file
BIN
Lib/7z-x64.dll
Normal file
Binary file not shown.
BIN
Lib/7z.dll
Normal file
BIN
Lib/7z.dll
Normal file
Binary file not shown.
|
@ -45,6 +45,9 @@
|
|||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\packages\AsyncBridge.Net35.0.2.0\lib\net35-Client\AsyncBridge.Net35.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="SevenZipSharp">
|
||||
<HintPath>..\packages\SevenZipSharp.0.64\lib\SevenZipSharp.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Drawing" />
|
||||
|
|
|
@ -45,7 +45,7 @@ public FFmpegCLIHelper(ScreencastOptions options)
|
|||
|
||||
if (string.IsNullOrEmpty(Options.FFmpeg.CLIPath))
|
||||
{
|
||||
Options.FFmpeg.CLIPath = Path.Combine(Application.StartupPath, "ffmpeg.exe");
|
||||
Options.FFmpeg.CLIPath = "ffmpeg.exe";
|
||||
}
|
||||
|
||||
Helpers.CreateDirectoryIfNotExist(Options.OutputPath);
|
||||
|
|
|
@ -44,11 +44,12 @@ private void InitializeComponent()
|
|||
this.groupBoxH263 = new System.Windows.Forms.GroupBox();
|
||||
this.labelQscale = new System.Windows.Forms.Label();
|
||||
this.groupBoxFFmpegExe = new System.Windows.Forms.GroupBox();
|
||||
this.btnDownload = new System.Windows.Forms.Button();
|
||||
this.buttonFFmpegBrowse = new System.Windows.Forms.Button();
|
||||
this.textBoxFFmpegPath = new System.Windows.Forms.TextBox();
|
||||
this.groupBoxCommandLinePreview = new System.Windows.Forms.GroupBox();
|
||||
this.textBoxCommandLinePreview = new System.Windows.Forms.TextBox();
|
||||
this.groupBox1 = new System.Windows.Forms.GroupBox();
|
||||
this.gbCommandLineArgs = new System.Windows.Forms.GroupBox();
|
||||
this.buttonFFmpegHelp = new System.Windows.Forms.Button();
|
||||
this.textBoxUserArgs = new System.Windows.Forms.TextBox();
|
||||
((System.ComponentModel.ISupportInitialize)(this.nudCRF)).BeginInit();
|
||||
|
@ -57,13 +58,13 @@ private void InitializeComponent()
|
|||
this.groupBoxH263.SuspendLayout();
|
||||
this.groupBoxFFmpegExe.SuspendLayout();
|
||||
this.groupBoxCommandLinePreview.SuspendLayout();
|
||||
this.groupBox1.SuspendLayout();
|
||||
this.gbCommandLineArgs.SuspendLayout();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// lblExt
|
||||
//
|
||||
this.lblExt.AutoSize = true;
|
||||
this.lblExt.Location = new System.Drawing.Point(256, 13);
|
||||
this.lblExt.Location = new System.Drawing.Point(240, 13);
|
||||
this.lblExt.Name = "lblExt";
|
||||
this.lblExt.Size = new System.Drawing.Size(56, 13);
|
||||
this.lblExt.TabIndex = 11;
|
||||
|
@ -128,9 +129,9 @@ private void InitializeComponent()
|
|||
"mp4",
|
||||
"webm",
|
||||
"avi"});
|
||||
this.comboBoxExtension.Location = new System.Drawing.Point(335, 8);
|
||||
this.comboBoxExtension.Location = new System.Drawing.Point(304, 9);
|
||||
this.comboBoxExtension.Name = "comboBoxExtension";
|
||||
this.comboBoxExtension.Size = new System.Drawing.Size(121, 21);
|
||||
this.comboBoxExtension.Size = new System.Drawing.Size(152, 21);
|
||||
this.comboBoxExtension.TabIndex = 15;
|
||||
//
|
||||
// lblCodec
|
||||
|
@ -146,9 +147,9 @@ private void InitializeComponent()
|
|||
//
|
||||
this.comboBoxCodec.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
|
||||
this.comboBoxCodec.FormattingEnabled = true;
|
||||
this.comboBoxCodec.Location = new System.Drawing.Point(88, 8);
|
||||
this.comboBoxCodec.Location = new System.Drawing.Point(64, 9);
|
||||
this.comboBoxCodec.Name = "comboBoxCodec";
|
||||
this.comboBoxCodec.Size = new System.Drawing.Size(121, 21);
|
||||
this.comboBoxCodec.Size = new System.Drawing.Size(160, 21);
|
||||
this.comboBoxCodec.TabIndex = 17;
|
||||
//
|
||||
// comboBoxPreset
|
||||
|
@ -204,6 +205,7 @@ private void InitializeComponent()
|
|||
//
|
||||
// groupBoxFFmpegExe
|
||||
//
|
||||
this.groupBoxFFmpegExe.Controls.Add(this.btnDownload);
|
||||
this.groupBoxFFmpegExe.Controls.Add(this.buttonFFmpegBrowse);
|
||||
this.groupBoxFFmpegExe.Controls.Add(this.textBoxFFmpegPath);
|
||||
this.groupBoxFFmpegExe.Location = new System.Drawing.Point(8, 144);
|
||||
|
@ -213,11 +215,21 @@ private void InitializeComponent()
|
|||
this.groupBoxFFmpegExe.TabStop = false;
|
||||
this.groupBoxFFmpegExe.Text = "ffmpeg.exe";
|
||||
//
|
||||
// btnDownload
|
||||
//
|
||||
this.btnDownload.Location = new System.Drawing.Point(368, 22);
|
||||
this.btnDownload.Name = "btnDownload";
|
||||
this.btnDownload.Size = new System.Drawing.Size(72, 24);
|
||||
this.btnDownload.TabIndex = 26;
|
||||
this.btnDownload.Text = "Download";
|
||||
this.btnDownload.UseVisualStyleBackColor = true;
|
||||
this.btnDownload.Click += new System.EventHandler(this.btnDownload_Click);
|
||||
//
|
||||
// buttonFFmpegBrowse
|
||||
//
|
||||
this.buttonFFmpegBrowse.Location = new System.Drawing.Point(408, 24);
|
||||
this.buttonFFmpegBrowse.Location = new System.Drawing.Point(320, 22);
|
||||
this.buttonFFmpegBrowse.Name = "buttonFFmpegBrowse";
|
||||
this.buttonFFmpegBrowse.Size = new System.Drawing.Size(35, 20);
|
||||
this.buttonFFmpegBrowse.Size = new System.Drawing.Size(40, 24);
|
||||
this.buttonFFmpegBrowse.TabIndex = 1;
|
||||
this.buttonFFmpegBrowse.Text = "...";
|
||||
this.buttonFFmpegBrowse.UseVisualStyleBackColor = true;
|
||||
|
@ -225,11 +237,9 @@ private void InitializeComponent()
|
|||
//
|
||||
// textBoxFFmpegPath
|
||||
//
|
||||
this.textBoxFFmpegPath.AutoCompleteMode = System.Windows.Forms.AutoCompleteMode.SuggestAppend;
|
||||
this.textBoxFFmpegPath.AutoCompleteSource = System.Windows.Forms.AutoCompleteSource.FileSystem;
|
||||
this.textBoxFFmpegPath.Location = new System.Drawing.Point(8, 24);
|
||||
this.textBoxFFmpegPath.Name = "textBoxFFmpegPath";
|
||||
this.textBoxFFmpegPath.Size = new System.Drawing.Size(392, 20);
|
||||
this.textBoxFFmpegPath.Size = new System.Drawing.Size(304, 20);
|
||||
this.textBoxFFmpegPath.TabIndex = 0;
|
||||
//
|
||||
// groupBoxCommandLinePreview
|
||||
|
@ -247,25 +257,26 @@ private void InitializeComponent()
|
|||
this.textBoxCommandLinePreview.Location = new System.Drawing.Point(8, 24);
|
||||
this.textBoxCommandLinePreview.Multiline = true;
|
||||
this.textBoxCommandLinePreview.Name = "textBoxCommandLinePreview";
|
||||
this.textBoxCommandLinePreview.ReadOnly = true;
|
||||
this.textBoxCommandLinePreview.Size = new System.Drawing.Size(432, 64);
|
||||
this.textBoxCommandLinePreview.TabIndex = 0;
|
||||
//
|
||||
// groupBox1
|
||||
// gbCommandLineArgs
|
||||
//
|
||||
this.groupBox1.Controls.Add(this.buttonFFmpegHelp);
|
||||
this.groupBox1.Controls.Add(this.textBoxUserArgs);
|
||||
this.groupBox1.Location = new System.Drawing.Point(8, 208);
|
||||
this.groupBox1.Name = "groupBox1";
|
||||
this.groupBox1.Size = new System.Drawing.Size(448, 56);
|
||||
this.groupBox1.TabIndex = 25;
|
||||
this.groupBox1.TabStop = false;
|
||||
this.groupBox1.Text = "Additional command line arguments";
|
||||
this.gbCommandLineArgs.Controls.Add(this.buttonFFmpegHelp);
|
||||
this.gbCommandLineArgs.Controls.Add(this.textBoxUserArgs);
|
||||
this.gbCommandLineArgs.Location = new System.Drawing.Point(8, 208);
|
||||
this.gbCommandLineArgs.Name = "gbCommandLineArgs";
|
||||
this.gbCommandLineArgs.Size = new System.Drawing.Size(448, 56);
|
||||
this.gbCommandLineArgs.TabIndex = 25;
|
||||
this.gbCommandLineArgs.TabStop = false;
|
||||
this.gbCommandLineArgs.Text = "Additional command line arguments";
|
||||
//
|
||||
// buttonFFmpegHelp
|
||||
//
|
||||
this.buttonFFmpegHelp.Location = new System.Drawing.Point(408, 24);
|
||||
this.buttonFFmpegHelp.Location = new System.Drawing.Point(400, 22);
|
||||
this.buttonFFmpegHelp.Name = "buttonFFmpegHelp";
|
||||
this.buttonFFmpegHelp.Size = new System.Drawing.Size(35, 20);
|
||||
this.buttonFFmpegHelp.Size = new System.Drawing.Size(40, 24);
|
||||
this.buttonFFmpegHelp.TabIndex = 1;
|
||||
this.buttonFFmpegHelp.Text = "?";
|
||||
this.buttonFFmpegHelp.UseVisualStyleBackColor = true;
|
||||
|
@ -277,23 +288,23 @@ private void InitializeComponent()
|
|||
this.textBoxUserArgs.AutoCompleteSource = System.Windows.Forms.AutoCompleteSource.FileSystem;
|
||||
this.textBoxUserArgs.Location = new System.Drawing.Point(8, 24);
|
||||
this.textBoxUserArgs.Name = "textBoxUserArgs";
|
||||
this.textBoxUserArgs.Size = new System.Drawing.Size(392, 20);
|
||||
this.textBoxUserArgs.Size = new System.Drawing.Size(384, 20);
|
||||
this.textBoxUserArgs.TabIndex = 0;
|
||||
//
|
||||
// FFmpegCLIOptionsForm
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(464, 377);
|
||||
this.Controls.Add(this.groupBox1);
|
||||
this.ClientSize = new System.Drawing.Size(464, 378);
|
||||
this.Controls.Add(this.gbCommandLineArgs);
|
||||
this.Controls.Add(this.groupBoxCommandLinePreview);
|
||||
this.Controls.Add(this.groupBoxFFmpegExe);
|
||||
this.Controls.Add(this.groupBoxH263);
|
||||
this.Controls.Add(this.groupBoxH264);
|
||||
this.Controls.Add(this.comboBoxCodec);
|
||||
this.Controls.Add(this.lblCodec);
|
||||
this.Controls.Add(this.comboBoxExtension);
|
||||
this.Controls.Add(this.lblExt);
|
||||
this.Controls.Add(this.groupBoxFFmpegExe);
|
||||
this.MaximizeBox = false;
|
||||
this.MinimizeBox = false;
|
||||
this.MinimumSize = new System.Drawing.Size(480, 416);
|
||||
|
@ -311,8 +322,8 @@ private void InitializeComponent()
|
|||
this.groupBoxFFmpegExe.PerformLayout();
|
||||
this.groupBoxCommandLinePreview.ResumeLayout(false);
|
||||
this.groupBoxCommandLinePreview.PerformLayout();
|
||||
this.groupBox1.ResumeLayout(false);
|
||||
this.groupBox1.PerformLayout();
|
||||
this.gbCommandLineArgs.ResumeLayout(false);
|
||||
this.gbCommandLineArgs.PerformLayout();
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
|
||||
|
@ -338,8 +349,9 @@ private void InitializeComponent()
|
|||
private System.Windows.Forms.TextBox textBoxFFmpegPath;
|
||||
private System.Windows.Forms.GroupBox groupBoxCommandLinePreview;
|
||||
private System.Windows.Forms.TextBox textBoxCommandLinePreview;
|
||||
private System.Windows.Forms.GroupBox groupBox1;
|
||||
private System.Windows.Forms.GroupBox gbCommandLineArgs;
|
||||
private System.Windows.Forms.Button buttonFFmpegHelp;
|
||||
private System.Windows.Forms.TextBox textBoxUserArgs;
|
||||
private System.Windows.Forms.Button btnDownload;
|
||||
}
|
||||
}
|
|
@ -1,4 +1,30 @@
|
|||
using HelpersLib;
|
||||
#region License Information (GPL v3)
|
||||
|
||||
/*
|
||||
ShareX - A program that allows you to take screenshots and share any file type
|
||||
Copyright (C) 2008-2014 ShareX Developers
|
||||
|
||||
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)
|
||||
|
||||
using HelpersLib;
|
||||
using SevenZip;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
|
@ -7,6 +33,7 @@
|
|||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace ScreenCaptureLib
|
||||
|
@ -49,9 +76,12 @@ private void LoadSettings()
|
|||
textBoxUserArgs.Text = Options.FFmpeg.UserArgs;
|
||||
textBoxUserArgs.TextChanged += (sender, e) => UpdateUI();
|
||||
|
||||
string cli = Path.Combine(Application.StartupPath, "ffmpeg.exe");
|
||||
string cli = "ffmpeg.exe";
|
||||
if (string.IsNullOrEmpty(Options.FFmpeg.CLIPath) && File.Exists(cli))
|
||||
{
|
||||
Options.FFmpeg.CLIPath = cli;
|
||||
}
|
||||
|
||||
textBoxFFmpegPath.Text = Options.FFmpeg.CLIPath;
|
||||
textBoxFFmpegPath.TextChanged += (sender, e) => UpdateUI();
|
||||
}
|
||||
|
@ -96,5 +126,81 @@ private void buttonFFmpegHelp_Click(object sender, EventArgs e)
|
|||
{
|
||||
Helpers.OpenURL("https://www.ffmpeg.org/ffmpeg.html");
|
||||
}
|
||||
|
||||
private void btnDownload_Click(object sender, EventArgs e)
|
||||
{
|
||||
string url;
|
||||
|
||||
if (NativeMethods.Is64Bit())
|
||||
{
|
||||
url = "http://ffmpeg.zeranoe.com/builds/win64/static/ffmpeg-latest-win64-static.7z";
|
||||
}
|
||||
else
|
||||
{
|
||||
url = "http://ffmpeg.zeranoe.com/builds/win32/static/ffmpeg-latest-win32-static.7z";
|
||||
}
|
||||
|
||||
using (DownloaderForm form = new DownloaderForm(url, "ffmpeg.7z"))
|
||||
{
|
||||
//form.Proxy =
|
||||
form.InstallType = InstallType.Event;
|
||||
form.InstallRequested += form_InstallRequested;
|
||||
form.ShowDialog();
|
||||
}
|
||||
}
|
||||
|
||||
private void form_InstallRequested(string filePath)
|
||||
{
|
||||
string extractPath = Path.Combine(Application.StartupPath, "ffmpeg.exe");
|
||||
bool result = ExtractFFmpeg(filePath, extractPath);
|
||||
|
||||
if (result)
|
||||
{
|
||||
this.InvokeSafe(() => textBoxFFmpegPath.Text = "ffmpeg.exe");
|
||||
MessageBox.Show("FFmpeg successfully downloaded.", "ShareX", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show("Download of FFmpeg failed.", "ShareX", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
|
||||
private bool ExtractFFmpeg(string zipPath, string extractPath)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (NativeMethods.Is64Bit())
|
||||
{
|
||||
SevenZipExtractor.SetLibraryPath(Path.Combine(Application.StartupPath, "7z-x64.dll"));
|
||||
}
|
||||
else
|
||||
{
|
||||
SevenZipExtractor.SetLibraryPath(Path.Combine(Application.StartupPath, "7z.dll"));
|
||||
}
|
||||
|
||||
using (SevenZipExtractor zip = new SevenZipExtractor(zipPath))
|
||||
{
|
||||
Regex regex = new Regex(@"^ffmpeg-.+\\bin\\ffmpeg\.exe$", RegexOptions.Compiled | RegexOptions.CultureInvariant);
|
||||
|
||||
foreach (ArchiveFileInfo item in zip.ArchiveFileData)
|
||||
{
|
||||
if (regex.IsMatch(item.FileName))
|
||||
{
|
||||
using (FileStream fs = new FileStream(extractPath, FileMode.Create, FileAccess.Write, FileShare.None))
|
||||
{
|
||||
zip.ExtractFile(item.Index, fs);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
DebugHelper.WriteException(e);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,5 +1,6 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<packages>
|
||||
<package id="AsyncBridge.Net35" version="0.2.0" targetFramework="net35" />
|
||||
<package id="SevenZipSharp" version="0.64" targetFramework="net35" />
|
||||
<package id="TaskParallelLibrary" version="1.0.2856.0" targetFramework="net35" />
|
||||
</packages>
|
|
@ -441,7 +441,7 @@ private void CheckUpdate()
|
|||
MessageBox.Show("An update is available for ShareX.\r\nWould you like to download it?", "ShareX",
|
||||
MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1) == DialogResult.Yes)
|
||||
{
|
||||
using (UpdaterForm updaterForm = new UpdaterForm(updateChecker))
|
||||
using (DownloaderForm updaterForm = new DownloaderForm(updateChecker))
|
||||
{
|
||||
updaterForm.ShowDialog();
|
||||
|
||||
|
|
|
@ -98,6 +98,12 @@ public async void StartRecording(TaskSettings TaskSettings)
|
|||
}
|
||||
}
|
||||
|
||||
if (TaskSettings.CaptureSettings.ScreenRecordOutput == ScreenRecordOutput.FFmpegCLI && !File.Exists(TaskSettings.CaptureSettings.FFmpegOptions.CLIPath))
|
||||
{
|
||||
MessageBox.Show("FFmpeg CLI file does not exist: " + TaskSettings.CaptureSettings.FFmpegOptions.CLIPath + "\r\nYou can automatically download it from FFmpeg options window.",
|
||||
Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Warning);
|
||||
}
|
||||
|
||||
SelectRegion();
|
||||
Screenshot.CaptureCursor = TaskSettings.CaptureSettings.ShowCursor;
|
||||
|
||||
|
|
|
@ -459,9 +459,6 @@
|
|||
<None Include="Resources\bug.png" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="LICENSE.txt">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</None>
|
||||
<None Include="Resources\checkbox_uncheck.png" />
|
||||
<None Include="Resources\checkbox_check.png" />
|
||||
<None Include="Resources\network-ip.png" />
|
||||
|
@ -470,6 +467,18 @@
|
|||
<None Include="Resources\Test.png" />
|
||||
<None Include="Resources\application-network.png" />
|
||||
<None Include="Resources\Greenshot.png" />
|
||||
<None Include="..\Docs\LICENSE.txt">
|
||||
<Link>LICENSE.txt</Link>
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</None>
|
||||
<None Include="..\Lib\7z-x64.dll">
|
||||
<Link>7z-x64.dll</Link>
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</None>
|
||||
<None Include="..\Lib\7z.dll">
|
||||
<Link>7z.dll</Link>
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</None>
|
||||
<Content Include="ShareX_Icon.ico" />
|
||||
<None Include="Resources\ru.png" />
|
||||
<None Include="Resources\keyboard--pencil.png" />
|
||||
|
@ -482,9 +491,10 @@
|
|||
<None Include="Resources\folder-tree.png" />
|
||||
<None Include="Resources\fr.png" />
|
||||
<None Include="Resources\color.png" />
|
||||
<Content Include="..\Docs\VersionHistory.txt">
|
||||
<None Include="..\Docs\VersionHistory.txt">
|
||||
<Link>VersionHistory.txt</Link>
|
||||
</Content>
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</None>
|
||||
<None Include="Resources\image-saturation.png" />
|
||||
<None Include="Resources\pipette.png" />
|
||||
</ItemGroup>
|
||||
|
|
Loading…
Reference in a new issue