Bye FFmpegNet, Hello ffmpeg.exe

This commit is contained in:
McoreD 2014-05-09 17:00:42 +08:00
parent f896ece866
commit b47c65f6c5
14 changed files with 1 additions and 483 deletions

View file

@ -229,8 +229,6 @@ public enum ScreenRecordOutput
AVI,
[Description("FFmpeg CLI")]
FFmpegCLI,
[Description("AVI via AForge.NET FFmpeg")]
FFmpegNet,
}
public enum DownloaderFormStatus

Binary file not shown.

Binary file not shown.

View file

@ -47,20 +47,6 @@ public enum NodePosition
Left
}
public enum FFmpegNetVideoCodec
{
Default = -1,
MPEG4 = 0,
WMV1 = 1,
WMV2 = 2,
MSMPEG4v2 = 3,
MSMPEG4v3 = 4,
H263P = 5,
FLV1 = 6,
MPEG2 = 7,
Raw = 8,
}
public enum FFmpegVideoCodec
{
[Description("x264")]

View file

@ -41,12 +41,6 @@
<GenerateSerializationAssemblies>Off</GenerateSerializationAssemblies>
</PropertyGroup>
<ItemGroup>
<Reference Include="AForge.Video">
<HintPath>..\Lib\AForge.Video.dll</HintPath>
</Reference>
<Reference Include="AForge.Video.FFMPEG">
<HintPath>..\Lib\AForge.Video.FFMPEG.dll</HintPath>
</Reference>
<Reference Include="AsyncBridge.Net35, Version=0.0.0.0, Culture=neutral, PublicKeyToken=b3b1c0202c0d6a87, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\packages\AsyncBridge.Net35.0.2.0\lib\net35-Client\AsyncBridge.Net35.dll</HintPath>
@ -73,13 +67,6 @@
</Compile>
<Compile Include="Screencast\ScreencastOptions.cs" />
<Compile Include="Screencast\AviWriter.cs" />
<Compile Include="Screencast\FFmpegCache.cs" />
<Compile Include="Screencast\FFmpegOptionsForm.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="Screencast\FFmpegOptionsForm.Designer.cs">
<DependentUpon>FFmpegOptionsForm.cs</DependentUpon>
</Compile>
<Compile Include="Forms\RectangleLight.cs">
<SubType>Form</SubType>
</Compile>
@ -158,9 +145,6 @@
<EmbeddedResource Include="Screencast\FFmpegCLIOptionsForm.resx">
<DependentUpon>FFmpegCLIOptionsForm.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Screencast\FFmpegOptionsForm.resx">
<DependentUpon>FFmpegOptionsForm.cs</DependentUpon>
</EmbeddedResource>
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />

View file

@ -1,74 +0,0 @@
#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 AForge.Video.FFMPEG;
using HelpersLib;
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace ScreenCaptureLib
{
public class FFmpegCache : ImageCache
{
private static readonly string[] ffmpegFiles = new string[] { "avcodec-53.dll", "avdevice-53.dll", "avfilter-2.dll", "avformat-53.dll", "avutil-51.dll", "swresample-0.dll", "swscale-2.dll" };
private VideoFileWriter ffmpegWriter;
public FFmpegCache(ScreencastOptions options)
{
Options = options;
Helpers.CreateDirectoryIfNotExist(Options.OutputPath);
ffmpegWriter = new VideoFileWriter();
ffmpegWriter.Open(options.OutputPath, options.Size.Width, options.Size.Height, options.FPS, (AForge.Video.FFMPEG.VideoCodec)options.FFmpegNet.VideoCodec, options.FFmpegNet.BitRate * 1000);
}
protected override void WriteFrame(Image img)
{
ffmpegWriter.WriteVideoFrame((Bitmap)img);
}
public override void Dispose()
{
if (ffmpegWriter != null)
{
ffmpegWriter.Dispose();
}
base.Dispose();
}
public static bool HasDependencies()
{
return ffmpegFiles.Select(x => Path.Combine(Application.StartupPath, x)).All(x => File.Exists(x));
}
}
}

View file

@ -1,135 +0,0 @@
namespace ScreenCaptureLib
{
partial class FFmpegOptionsForm
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.btnCancel = new System.Windows.Forms.Button();
this.btnOK = new System.Windows.Forms.Button();
this.comboBoxCodecs = new System.Windows.Forms.ComboBox();
this.lblCodec = new System.Windows.Forms.Label();
this.nudBitrate = new System.Windows.Forms.NumericUpDown();
this.lblBitrate = new System.Windows.Forms.Label();
((System.ComponentModel.ISupportInitialize)(this.nudBitrate)).BeginInit();
this.SuspendLayout();
//
// btnCancel
//
this.btnCancel.Location = new System.Drawing.Point(224, 44);
this.btnCancel.Name = "btnCancel";
this.btnCancel.Size = new System.Drawing.Size(75, 23);
this.btnCancel.TabIndex = 10;
this.btnCancel.Text = "Cancel";
this.btnCancel.UseVisualStyleBackColor = true;
this.btnCancel.Click += new System.EventHandler(this.btnCancel_Click);
//
// btnOK
//
this.btnOK.Location = new System.Drawing.Point(224, 12);
this.btnOK.Name = "btnOK";
this.btnOK.Size = new System.Drawing.Size(75, 23);
this.btnOK.TabIndex = 9;
this.btnOK.Text = "OK";
this.btnOK.UseVisualStyleBackColor = true;
this.btnOK.Click += new System.EventHandler(this.btnOK_Click);
//
// comboBoxCodecs
//
this.comboBoxCodecs.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.comboBoxCodecs.FormattingEnabled = true;
this.comboBoxCodecs.Location = new System.Drawing.Point(72, 12);
this.comboBoxCodecs.Name = "comboBoxCodecs";
this.comboBoxCodecs.Size = new System.Drawing.Size(136, 21);
this.comboBoxCodecs.TabIndex = 11;
this.comboBoxCodecs.SelectedIndexChanged += new System.EventHandler(this.comboBoxCodecs_SelectedIndexChanged);
//
// lblCodec
//
this.lblCodec.AutoSize = true;
this.lblCodec.Location = new System.Drawing.Point(8, 16);
this.lblCodec.Name = "lblCodec";
this.lblCodec.Size = new System.Drawing.Size(38, 13);
this.lblCodec.TabIndex = 12;
this.lblCodec.Text = "Codec";
//
// nudBitrate
//
this.nudBitrate.Location = new System.Drawing.Point(72, 44);
this.nudBitrate.Maximum = new decimal(new int[] {
9000,
0,
0,
0});
this.nudBitrate.Name = "nudBitrate";
this.nudBitrate.Size = new System.Drawing.Size(136, 20);
this.nudBitrate.TabIndex = 13;
this.nudBitrate.ValueChanged += new System.EventHandler(this.nudBitrate_ValueChanged);
//
// lblBitrate
//
this.lblBitrate.AutoSize = true;
this.lblBitrate.Location = new System.Drawing.Point(8, 48);
this.lblBitrate.Name = "lblBitrate";
this.lblBitrate.Size = new System.Drawing.Size(56, 13);
this.lblBitrate.TabIndex = 14;
this.lblBitrate.Text = "Bit rate (K)";
//
// FFmpegOptionsForm
//
this.AcceptButton = this.btnOK;
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(304, 90);
this.Controls.Add(this.lblBitrate);
this.Controls.Add(this.nudBitrate);
this.Controls.Add(this.lblCodec);
this.Controls.Add(this.comboBoxCodecs);
this.Controls.Add(this.btnCancel);
this.Controls.Add(this.btnOK);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
this.MaximizeBox = false;
this.MinimizeBox = false;
this.MinimumSize = new System.Drawing.Size(300, 128);
this.Name = "FFmpegOptionsForm";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "FFmpegOptionsForm";
((System.ComponentModel.ISupportInitialize)(this.nudBitrate)).EndInit();
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.Button btnCancel;
private System.Windows.Forms.Button btnOK;
private System.Windows.Forms.ComboBox comboBoxCodecs;
private System.Windows.Forms.Label lblCodec;
private System.Windows.Forms.NumericUpDown nudBitrate;
private System.Windows.Forms.Label lblBitrate;
}
}

View file

@ -1,77 +0,0 @@
#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 System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace ScreenCaptureLib
{
public partial class FFmpegOptionsForm : Form
{
private FFmpegNetOptions Options;
public FFmpegOptionsForm(FFmpegNetOptions options)
{
InitializeComponent();
Options = options;
this.Text = string.Format("{0} - FFmpeg Options", Application.ProductName);
this.Icon = ShareXResources.Icon;
comboBoxCodecs.Items.AddRange(Helpers.GetEnumDescriptions<FFmpegNetVideoCodec>());
comboBoxCodecs.SelectedIndex = (int)options.VideoCodec;
nudBitrate.Value = Options.BitRate;
}
private void btnOK_Click(object sender, EventArgs e)
{
DialogResult = DialogResult.OK;
Close();
}
private void btnCancel_Click(object sender, EventArgs e)
{
DialogResult = DialogResult.Cancel;
Close();
}
private void comboBoxCodecs_SelectedIndexChanged(object sender, EventArgs e)
{
Options.VideoCodec = (FFmpegNetVideoCodec)comboBoxCodecs.SelectedIndex;
}
private void nudBitrate_ValueChanged(object sender, EventArgs e)
{
Options.BitRate = (int)nudBitrate.Value;
}
}
}

View file

@ -1,120 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View file

@ -124,9 +124,6 @@ public ScreenRecorder(ScreencastOptions options, Rectangle captureRectangle, Scr
case ScreenRecordOutput.FFmpegCLI:
ffMpegCli = new FFmpegCLIHelper(Options);
break;
case ScreenRecordOutput.FFmpegNet:
imgCache = new FFmpegCache(Options);
break;
case ScreenRecordOutput.GIF:
imgCache = new HardDiskCache(Options);
break;

View file

@ -44,7 +44,6 @@ public class ScreencastOptions
public AVIOptions AVI = new AVIOptions();
public FFmpegOptions FFmpegCLI = new FFmpegOptions();
public FFmpegNetOptions FFmpegNet = new FFmpegNetOptions();
}
public class AVIOptions
@ -74,15 +73,4 @@ public FFmpegOptions()
Extension = "mp4";
}
}
public class FFmpegNetOptions
{
public FFmpegNetVideoCodec VideoCodec { get; set; }
public int BitRate { get; set; }
public FFmpegNetOptions()
{
VideoCodec = FFmpegNetVideoCodec.MPEG4;
}
}
}

View file

@ -83,25 +83,6 @@ private void SelectRegion()
public async void StartRecording(TaskSettings TaskSettings)
{
if (TaskSettings.CaptureSettings.ScreenRecordOutput == ScreenRecordOutput.FFmpegNet && !FFmpegCache.HasDependencies())
{
if (MessageBox.Show("FFmpeg files are not present. Would you like to download and install them?", Application.ProductName, MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes)
{
GitHubUpdateChecker updateChecker = new GitHubUpdateChecker("McoreD", "FFmpegNet");
updateChecker.Proxy = ProxyInfo.Current.GetWebProxy();
string downloadUrl = updateChecker.GetLatestDownloadURL();
if (!string.IsNullOrEmpty(downloadUrl))
{
UpdateInfo updateInfo = new UpdateInfo() { DownloadURL = downloadUrl };
using (UpdaterForm form = new UpdaterForm(updateInfo) { Proxy = ProxyInfo.Current.GetWebProxy() })
{
form.ShowDialog();
}
}
}
return;
}
if (TaskSettings.CaptureSettings.RunScreencastCLI)
{
if (!Program.Settings.VideoEncoders.IsValidIndex(TaskSettings.CaptureSettings.VideoEncoderSelected))
@ -140,8 +121,7 @@ public async void StartRecording(TaskSettings TaskSettings)
await TaskEx.Run(() =>
{
if (TaskSettings.CaptureSettings.ScreenRecordOutput == ScreenRecordOutput.AVI ||
TaskSettings.CaptureSettings.ScreenRecordOutput == ScreenRecordOutput.FFmpegNet)
if (TaskSettings.CaptureSettings.ScreenRecordOutput == ScreenRecordOutput.AVI)
{
path = Path.Combine(TaskSettings.CaptureFolder, TaskHelpers.GetFilename(TaskSettings, "avi"));
}
@ -162,7 +142,6 @@ public async void StartRecording(TaskSettings TaskSettings)
Duration = TaskSettings.CaptureSettings.ScreenRecordFixedDuration ? TaskSettings.CaptureSettings.ScreenRecordDuration : 0,
AVI = TaskSettings.CaptureSettings.AVIOptions,
FFmpegCLI = TaskSettings.CaptureSettings.FFmpegCLIOptions,
FFmpegNet = TaskSettings.CaptureSettings.FFmpegNetOptions
};
screenRecorder = new ScreenRecorder(options, CaptureRectangle, TaskSettings.CaptureSettings.ScreenRecordOutput);

View file

@ -647,7 +647,6 @@ private void cbScreenRecorderOutput_SelectedIndexChanged(object sender, EventArg
{
TaskSettings.CaptureSettings.ScreenRecordOutput = (ScreenRecordOutput)cbScreenRecorderOutput.SelectedIndex;
btnScreenRecorderOptions.Enabled = TaskSettings.CaptureSettings.ScreenRecordOutput == ScreenRecordOutput.AVI ||
TaskSettings.CaptureSettings.ScreenRecordOutput == ScreenRecordOutput.FFmpegNet ||
TaskSettings.CaptureSettings.ScreenRecordOutput == ScreenRecordOutput.FFmpegCLI;
btnEncoderConfig.Enabled = cboEncoder.Enabled = chkRunScreencastCLI.Enabled && chkRunScreencastCLI.Checked;
}
@ -687,12 +686,6 @@ private void btnScreenRecorderOptions_Click(object sender, EventArgs e)
form.ShowDialog();
}
break;
case ScreenRecordOutput.FFmpegNet:
using (FFmpegOptionsForm form = new FFmpegOptionsForm(TaskSettings.CaptureSettings.FFmpegNetOptions))
{
form.ShowDialog();
}
break;
}
}

View file

@ -280,7 +280,6 @@ public class TaskSettingsCapture
public ScreenRecordOutput ScreenRecordOutput = ScreenRecordOutput.GIF;
public AVIOptions AVIOptions = new AVIOptions();
public FFmpegOptions FFmpegCLIOptions = new FFmpegOptions();
public FFmpegNetOptions FFmpegNetOptions = new FFmpegNetOptions();
public int ScreenRecordFPS = 5;
public bool ScreenRecordFixedDuration = true;