mirror of
https://github.com/ShareX/ShareX.git
synced 2024-10-01 17:56:51 +13:00
FFmpeg options form test and copy buttons
This commit is contained in:
parent
6488c1c042
commit
b9af679c30
4 changed files with 63 additions and 11 deletions
|
@ -56,6 +56,8 @@ private void InitializeComponent()
|
|||
this.tpVpx = new System.Windows.Forms.TabPage();
|
||||
this.lblVpxCRF = new System.Windows.Forms.Label();
|
||||
this.tpXvid = new System.Windows.Forms.TabPage();
|
||||
this.btnTest = new System.Windows.Forms.Button();
|
||||
this.btnCopyPreview = new System.Windows.Forms.Button();
|
||||
((System.ComponentModel.ISupportInitialize)(this.nudx264CRF)).BeginInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.nudQscale)).BeginInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.nudVPxCRF)).BeginInit();
|
||||
|
@ -358,20 +360,42 @@ private void InitializeComponent()
|
|||
this.tpXvid.Text = "XviD";
|
||||
this.tpXvid.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// btnTest
|
||||
//
|
||||
this.btnTest.Location = new System.Drawing.Point(136, 243);
|
||||
this.btnTest.Name = "btnTest";
|
||||
this.btnTest.Size = new System.Drawing.Size(88, 23);
|
||||
this.btnTest.TabIndex = 1;
|
||||
this.btnTest.Text = "Test with CMD";
|
||||
this.btnTest.UseVisualStyleBackColor = true;
|
||||
this.btnTest.Click += new System.EventHandler(this.btnTest_Click);
|
||||
//
|
||||
// btnCopyPreview
|
||||
//
|
||||
this.btnCopyPreview.Location = new System.Drawing.Point(227, 243);
|
||||
this.btnCopyPreview.Name = "btnCopyPreview";
|
||||
this.btnCopyPreview.Size = new System.Drawing.Size(56, 23);
|
||||
this.btnCopyPreview.TabIndex = 1;
|
||||
this.btnCopyPreview.Text = "Copy";
|
||||
this.btnCopyPreview.UseVisualStyleBackColor = true;
|
||||
this.btnCopyPreview.Click += new System.EventHandler(this.btnCopyPreview_Click);
|
||||
//
|
||||
// FFmpegOptionsForm
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.BackColor = System.Drawing.Color.White;
|
||||
this.ClientSize = new System.Drawing.Size(464, 360);
|
||||
this.Controls.Add(this.btnCopyPreview);
|
||||
this.Controls.Add(this.btnTest);
|
||||
this.Controls.Add(this.cbCodec);
|
||||
this.Controls.Add(this.tcFFmpeg);
|
||||
this.Controls.Add(this.lblCodec);
|
||||
this.Controls.Add(this.gbCommandLineArgs);
|
||||
this.Controls.Add(this.cbExtension);
|
||||
this.Controls.Add(this.gbCommandLinePreview);
|
||||
this.Controls.Add(this.lblExt);
|
||||
this.Controls.Add(this.gbFFmpegExe);
|
||||
this.Controls.Add(this.gbCommandLineArgs);
|
||||
this.MaximizeBox = false;
|
||||
this.MinimizeBox = false;
|
||||
this.Name = "FFmpegOptionsForm";
|
||||
|
@ -427,5 +451,7 @@ private void InitializeComponent()
|
|||
private System.Windows.Forms.TabPage tpXvid;
|
||||
private System.Windows.Forms.NumericUpDown nudVPxCRF;
|
||||
private System.Windows.Forms.Label lblVpxCRF;
|
||||
private System.Windows.Forms.Button btnTest;
|
||||
private System.Windows.Forms.Button btnCopyPreview;
|
||||
}
|
||||
}
|
|
@ -30,6 +30,7 @@ You should have received a copy of the GNU General Public License
|
|||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Diagnostics;
|
||||
using System.Drawing;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
|
@ -129,7 +130,7 @@ public void SettingsSave()
|
|||
public void UpdateUI()
|
||||
{
|
||||
SettingsSave();
|
||||
tbCommandLinePreview.Text = Options.GetFFmpegArgs(true);
|
||||
tbCommandLinePreview.Text = Options.GetFFmpegArgs();
|
||||
}
|
||||
|
||||
public void UpdateExtensions()
|
||||
|
@ -182,5 +183,33 @@ private void DownloaderForm_InstallRequested(string filePath)
|
|||
MessageBox.Show("Download of FFmpeg failed.", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
|
||||
private void btnTest_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (File.Exists(Options.FFmpeg.CLIPath))
|
||||
{
|
||||
try
|
||||
{
|
||||
using (Process process = new Process())
|
||||
{
|
||||
ProcessStartInfo psi = new ProcessStartInfo(Options.FFmpeg.CLIPath);
|
||||
psi.Arguments = Options.GetFFmpegArgs();
|
||||
psi.WorkingDirectory = Path.GetDirectoryName(Options.FFmpeg.CLIPath);
|
||||
|
||||
process.StartInfo = psi;
|
||||
process.Start();
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
DebugHelper.WriteException(ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void btnCopyPreview_Click(object sender, EventArgs e)
|
||||
{
|
||||
ClipboardHelpers.CopyText("ffmpeg " + Options.GetFFmpegArgs());
|
||||
}
|
||||
}
|
||||
}
|
|
@ -48,15 +48,10 @@ public class ScreencastOptions
|
|||
|
||||
public FFmpegOptions FFmpeg = new FFmpegOptions();
|
||||
|
||||
public string GetFFmpegArgs(bool isPreview = false)
|
||||
public string GetFFmpegArgs()
|
||||
{
|
||||
StringBuilder args = new StringBuilder();
|
||||
|
||||
if (isPreview)
|
||||
{
|
||||
args.Append("ffmpeg ");
|
||||
}
|
||||
|
||||
// http://ffmpeg.org/ffmpeg-devices.html#gdigrab
|
||||
args.AppendFormat("-f gdigrab -framerate {0} -offset_x {1} -offset_y {2} -video_size {3}x{4} -draw_mouse {5} -show_region {6} -i desktop ",
|
||||
ScreenRecordFPS, CaptureArea.X, CaptureArea.Y, CaptureArea.Width, CaptureArea.Height, DrawCursor ? 1 : 0, 0);
|
||||
|
@ -99,7 +94,7 @@ public string GetFFmpegArgs(bool isPreview = false)
|
|||
// -y for overwrite file
|
||||
args.Append("-y ");
|
||||
|
||||
args.AppendFormat("\"{0}\"", Path.ChangeExtension(isPreview ? "output" : OutputPath, FFmpeg.Extension));
|
||||
args.AppendFormat("\"{0}\"", Path.ChangeExtension(OutputPath, FFmpeg.Extension));
|
||||
|
||||
return args.ToString();
|
||||
}
|
||||
|
|
|
@ -663,9 +663,9 @@ private void btnScreenRecorderOptions_Click(object sender, EventArgs e)
|
|||
ShowAVIOptionsDialog = true,
|
||||
GIFFPS = TaskSettings.CaptureSettings.GIFFPS,
|
||||
ScreenRecordFPS = TaskSettings.CaptureSettings.ScreenRecordFPS,
|
||||
OutputPath = Path.Combine(TaskSettings.CaptureFolder, TaskHelpers.GetFilename(TaskSettings, "avi")),
|
||||
OutputPath = "output.mp4",
|
||||
ParentWindow = this.Handle,
|
||||
CaptureArea = new Rectangle(0, 0, 100, 100)
|
||||
CaptureArea = Screen.PrimaryScreen.Bounds
|
||||
};
|
||||
|
||||
switch (TaskSettings.CaptureSettings.ScreenRecordOutput)
|
||||
|
@ -674,6 +674,8 @@ private void btnScreenRecorderOptions_Click(object sender, EventArgs e)
|
|||
|
||||
try
|
||||
{
|
||||
options.OutputPath = Program.ScreenRecorderCacheFilePath;
|
||||
|
||||
// Ugly workaround for show AVI compression dialog
|
||||
using (AVICache aviCache = new AVICache(options))
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue