Added GIF encoding options, using FFmpeg GIF encoding by default now

This commit is contained in:
Jaex 2015-06-04 12:07:43 +03:00
parent f03ea472f4
commit 94b2542ee4
8 changed files with 2501 additions and 1049 deletions

View file

@ -1474,6 +1474,33 @@ internal class Resources {
}
}
/// <summary>
/// Looks up a localized string similar to FFmpeg (Good quality).
/// </summary>
internal static string ScreenRecordGIFEncoding_FFmpeg {
get {
return ResourceManager.GetString("ScreenRecordGIFEncoding_FFmpeg", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to .NET (Bad quality).
/// </summary>
internal static string ScreenRecordGIFEncoding_NET {
get {
return ResourceManager.GetString("ScreenRecordGIFEncoding_NET", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Octree quantizer (Medium quality).
/// </summary>
internal static string ScreenRecordGIFEncoding_OctreeQuantizer {
get {
return ResourceManager.GetString("ScreenRecordGIFEncoding_OctreeQuantizer", resourceCulture);
}
}
/// <summary>
/// Looks up a localized resource of type System.Drawing.Icon similar to (Icon).
/// </summary>

View file

@ -637,4 +637,13 @@ Would you like to download and install it?</value>
<data name="HotkeyType_CustomRegion" xml:space="preserve">
<value>Capture custom region</value>
</data>
<data name="ScreenRecordGIFEncoding_FFmpeg" xml:space="preserve">
<value>FFmpeg (Good quality)</value>
</data>
<data name="ScreenRecordGIFEncoding_NET" xml:space="preserve">
<value>.NET (Bad quality)</value>
</data>
<data name="ScreenRecordGIFEncoding_OctreeQuantizer" xml:space="preserve">
<value>Octree quantizer (Medium quality)</value>
</data>
</root>

View file

@ -35,6 +35,16 @@ public enum ScreenRecordOutput
GIF
}
public enum ScreenRecordGIFEncoding
{
[Description("FFmpeg")]
FFmpeg,
[Description(".NET")]
NET,
[Description("Octree quantizer")]
OctreeQuantizer
}
public enum SurfaceResult
{
None,

View file

@ -90,6 +90,22 @@ private void TrayIcon_MouseClick(object sender, MouseEventArgs e)
public void StartRecording(ScreenRecordOutput outputType, TaskSettings taskSettings, bool skipRegionSelection = false)
{
string debugText;
if (outputType == ScreenRecordOutput.FFmpeg)
{
debugText = string.Format("Starting FFmpeg recording. Video encoder: \"{0}\", Audio encoder: \"{1}\", FPS: {2}",
taskSettings.CaptureSettings.FFmpegOptions.VideoCodec.GetDescription(), taskSettings.CaptureSettings.FFmpegOptions.AudioCodec.GetDescription(),
taskSettings.CaptureSettings.ScreenRecordFPS);
}
else
{
debugText = string.Format("Starting Animated GIF recording. GIF encoding: \"{0}\", FPS: {1}",
taskSettings.CaptureSettings.GIFEncoding.GetDescription(), taskSettings.CaptureSettings.GIFFPS);
}
DebugHelper.WriteLine(debugText);
if (taskSettings.CaptureSettings.RunScreencastCLI)
{
if (!Program.Settings.VideoEncoders.IsValidIndex(taskSettings.CaptureSettings.VideoEncoderSelected))
@ -108,6 +124,12 @@ public void StartRecording(ScreenRecordOutput outputType, TaskSettings taskSetti
}
}
if (outputType == ScreenRecordOutput.GIF && taskSettings.CaptureSettings.GIFEncoding == ScreenRecordGIFEncoding.FFmpeg)
{
outputType = ScreenRecordOutput.FFmpeg;
taskSettings.CaptureSettings.FFmpegOptions.VideoCodec = FFmpegVideoCodec.gif;
}
if (outputType == ScreenRecordOutput.FFmpeg)
{
if (!File.Exists(taskSettings.CaptureSettings.FFmpegOptions.CLIPath))
@ -277,7 +299,8 @@ public void StartRecording(ScreenRecordOutput outputType, TaskSettings taskSetti
{
path = Path.Combine(taskSettings.CaptureFolder, TaskHelpers.GetFilename(taskSettings, "gif"));
screenRecorder.EncodingProgressChanged += progress => TrayIcon.Text = string.Format("ShareX - {0} ({1}%)", Resources.ScreenRecordForm_StartRecording_Encoding___, progress);
screenRecorder.SaveAsGIF(path, taskSettings.ImageSettings.ImageGIFQuality);
GIFQuality gifQuality = taskSettings.CaptureSettings.GIFEncoding == ScreenRecordGIFEncoding.OctreeQuantizer ? GIFQuality.Bit8 : GIFQuality.Default;
screenRecorder.SaveAsGIF(path, gifQuality);
}
else if (outputType == ScreenRecordOutput.FFmpeg && taskSettings.CaptureSettings.FFmpegOptions.VideoCodec == FFmpegVideoCodec.gif)
{

View file

@ -127,6 +127,8 @@ private void InitializeComponent()
this.tpRegionCapture = new System.Windows.Forms.TabPage();
this.pgRegionCapture = new System.Windows.Forms.PropertyGrid();
this.tpScreenRecorder = new System.Windows.Forms.TabPage();
this.cbGIFEncoding = new System.Windows.Forms.ComboBox();
this.lblGIFEncoding = new System.Windows.Forms.Label();
this.btnScreenRecorderFFmpegOptions = new System.Windows.Forms.Button();
this.lblScreenRecorderStartDelay = new System.Windows.Forms.Label();
this.chkScreenRecordAutoStart = new System.Windows.Forms.CheckBox();
@ -1023,6 +1025,8 @@ private void InitializeComponent()
//
// tpScreenRecorder
//
this.tpScreenRecorder.Controls.Add(this.cbGIFEncoding);
this.tpScreenRecorder.Controls.Add(this.lblGIFEncoding);
this.tpScreenRecorder.Controls.Add(this.btnScreenRecorderFFmpegOptions);
this.tpScreenRecorder.Controls.Add(this.lblScreenRecorderStartDelay);
this.tpScreenRecorder.Controls.Add(this.chkScreenRecordAutoStart);
@ -1041,6 +1045,19 @@ private void InitializeComponent()
this.tpScreenRecorder.Name = "tpScreenRecorder";
this.tpScreenRecorder.UseVisualStyleBackColor = true;
//
// cbGIFEncoding
//
this.cbGIFEncoding.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.cbGIFEncoding.FormattingEnabled = true;
resources.ApplyResources(this.cbGIFEncoding, "cbGIFEncoding");
this.cbGIFEncoding.Name = "cbGIFEncoding";
this.cbGIFEncoding.SelectedIndexChanged += new System.EventHandler(this.cbGIFEncoding_SelectedIndexChanged);
//
// lblGIFEncoding
//
resources.ApplyResources(this.lblGIFEncoding, "lblGIFEncoding");
this.lblGIFEncoding.Name = "lblGIFEncoding";
//
// btnScreenRecorderFFmpegOptions
//
resources.ApplyResources(this.btnScreenRecorderFFmpegOptions, "btnScreenRecorderFFmpegOptions");
@ -1795,6 +1812,8 @@ private void InitializeComponent()
private System.Windows.Forms.NumericUpDown nudCaptureCustomRegionY;
private System.Windows.Forms.NumericUpDown nudCaptureCustomRegionX;
private System.Windows.Forms.Button btnCaptureTransmitBoundsFromMonitorToCustomBounds;
private System.Windows.Forms.ComboBox cbGIFEncoding;
private System.Windows.Forms.Label lblGIFEncoding;

View file

@ -228,6 +228,8 @@ public TaskSettingsForm(TaskSettings hotkeySetting, bool isDefault = false)
// Capture / Screen recorder
nudScreenRecordFPS.Value = TaskSettings.CaptureSettings.ScreenRecordFPS.Between((int)nudScreenRecordFPS.Minimum, (int)nudScreenRecordFPS.Maximum);
nudGIFFPS.Value = TaskSettings.CaptureSettings.GIFFPS.Between((int)nudGIFFPS.Minimum, (int)nudGIFFPS.Maximum);
cbGIFEncoding.Items.AddRange(Helpers.GetLocalizedEnumDescriptions<ScreenRecordGIFEncoding>());
cbGIFEncoding.SelectedIndex = (int)TaskSettings.CaptureSettings.GIFEncoding;
cbScreenRecorderFixedDuration.Checked = nudScreenRecorderDuration.Enabled = TaskSettings.CaptureSettings.ScreenRecordFixedDuration;
nudScreenRecorderDuration.Value = (decimal)TaskSettings.CaptureSettings.ScreenRecordDuration;
chkScreenRecordAutoStart.Checked = nudScreenRecorderStartDelay.Enabled = TaskSettings.CaptureSettings.ScreenRecordAutoStart;
@ -862,6 +864,11 @@ private void nudGIFFPS_ValueChanged(object sender, EventArgs e)
}
}
private void cbGIFEncoding_SelectedIndexChanged(object sender, EventArgs e)
{
TaskSettings.CaptureSettings.GIFEncoding = (ScreenRecordGIFEncoding)cbGIFEncoding.SelectedIndex;
}
private void cbScreenRecorderFixedDuration_CheckedChanged(object sender, EventArgs e)
{
TaskSettings.CaptureSettings.ScreenRecordFixedDuration = cbScreenRecorderFixedDuration.Checked;

File diff suppressed because it is too large Load diff

View file

@ -299,6 +299,7 @@ public class TaskSettingsCapture
public FFmpegOptions FFmpegOptions = new FFmpegOptions();
public int ScreenRecordFPS = 20;
public int GIFFPS = 5;
public ScreenRecordGIFEncoding GIFEncoding = ScreenRecordGIFEncoding.FFmpeg;
public bool ScreenRecordFixedDuration = false;
public float ScreenRecordDuration = 3f;
public bool ScreenRecordAutoStart = true;