mirror of
https://github.com/ShareX/ShareX.git
synced 2024-10-01 17:56:51 +13:00
FFmpeg custom commands now support $fps$, $duration$, $output$ variables
This commit is contained in:
parent
713b4a6682
commit
720a6b3de7
6 changed files with 61 additions and 52 deletions
|
@ -375,10 +375,12 @@ private void InitializeComponent()
|
|||
// txtCommandLinePreview
|
||||
//
|
||||
this.txtCommandLinePreview.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.txtCommandLinePreview.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(162)));
|
||||
this.txtCommandLinePreview.Location = new System.Drawing.Point(8, 21);
|
||||
this.txtCommandLinePreview.Multiline = true;
|
||||
this.txtCommandLinePreview.Name = "txtCommandLinePreview";
|
||||
this.txtCommandLinePreview.ReadOnly = true;
|
||||
this.txtCommandLinePreview.ScrollBars = System.Windows.Forms.ScrollBars.Vertical;
|
||||
this.txtCommandLinePreview.Size = new System.Drawing.Size(632, 67);
|
||||
this.txtCommandLinePreview.TabIndex = 0;
|
||||
this.txtCommandLinePreview.TextChanged += new System.EventHandler(this.txtCommandLinePreview_TextChanged);
|
||||
|
|
|
@ -48,7 +48,6 @@ public FFmpegOptionsForm(ScreencastOptions options)
|
|||
if (Options != null)
|
||||
{
|
||||
SettingsLoad();
|
||||
UpdateUI();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -94,7 +93,12 @@ private void SettingsLoad()
|
|||
|
||||
cbCustomCommands.Checked = Options.FFmpeg.UseCustomCommands;
|
||||
|
||||
txtCommandLinePreview.Text = Options.GetFFmpegCommands();
|
||||
if (Options.FFmpeg.UseCustomCommands)
|
||||
{
|
||||
txtCommandLinePreview.Text = Options.FFmpeg.CustomCommands;
|
||||
}
|
||||
|
||||
UpdateUI();
|
||||
}
|
||||
|
||||
private void RefreshSourcesAsync()
|
||||
|
@ -134,7 +138,7 @@ public void UpdateUI()
|
|||
|
||||
if (!Options.FFmpeg.UseCustomCommands)
|
||||
{
|
||||
txtCommandLinePreview.Text = Options.GetFFmpegCommands();
|
||||
txtCommandLinePreview.Text = Options.GetFFmpegArgs();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -337,9 +341,13 @@ private void cbCustomCommands_CheckedChanged(object sender, EventArgs e)
|
|||
Options.FFmpeg.UseCustomCommands = cbCustomCommands.Checked;
|
||||
txtCommandLinePreview.ReadOnly = !Options.FFmpeg.UseCustomCommands;
|
||||
|
||||
if (!Options.FFmpeg.UseCustomCommands)
|
||||
if (Options.FFmpeg.UseCustomCommands)
|
||||
{
|
||||
txtCommandLinePreview.Text = Options.GetFFmpegCommands();
|
||||
txtCommandLinePreview.Text = Options.GetFFmpegArgs(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
txtCommandLinePreview.Text = Options.GetFFmpegArgs();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -26,6 +26,7 @@ You should have received a copy of the GNU General Public License
|
|||
using HelpersLib;
|
||||
using System;
|
||||
using System.Drawing;
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
|
||||
|
@ -48,6 +49,8 @@ public class ScreencastOptions
|
|||
|
||||
public string GetFFmpegCommands()
|
||||
{
|
||||
string commands;
|
||||
|
||||
if (!string.IsNullOrEmpty(FFmpeg.VideoSource) && FFmpeg.VideoSource.Equals("screen-capture-recorder", StringComparison.InvariantCultureIgnoreCase))
|
||||
{
|
||||
// https://github.com/rdp/screen-capture-recorder-to-video-windows-free
|
||||
|
@ -62,27 +65,20 @@ public string GetFFmpegCommands()
|
|||
|
||||
if (FFmpeg.UseCustomCommands && !string.IsNullOrEmpty(FFmpeg.CustomCommands))
|
||||
{
|
||||
string commands = FFmpeg.CustomCommands.Trim();
|
||||
|
||||
// Replace output path
|
||||
if (commands[commands.Length - 1] == '"')
|
||||
{
|
||||
int index = commands.LastIndexOf('"', commands.Length - 2);
|
||||
|
||||
if (index >= 0)
|
||||
{
|
||||
commands = commands.Remove(index);
|
||||
commands += string.Format("\"{0}\"", Path.ChangeExtension(OutputPath, FFmpeg.Extension));
|
||||
}
|
||||
}
|
||||
|
||||
return commands;
|
||||
commands = FFmpeg.CustomCommands;
|
||||
commands = commands.Replace("$fps$", ScreenRecordFPS.ToString());
|
||||
commands = commands.Replace("$duration$", Duration.ToString("0.0", CultureInfo.InvariantCulture));
|
||||
commands = commands.Replace("$output$", Path.ChangeExtension(OutputPath, FFmpeg.Extension));
|
||||
}
|
||||
else
|
||||
{
|
||||
commands = GetFFmpegArgs();
|
||||
}
|
||||
|
||||
return GetFFmpegArgs();
|
||||
return commands.Trim();
|
||||
}
|
||||
|
||||
private string GetFFmpegArgs()
|
||||
public string GetFFmpegArgs(bool isCustom = false)
|
||||
{
|
||||
StringBuilder args = new StringBuilder();
|
||||
|
||||
|
@ -92,11 +88,13 @@ private string GetFFmpegArgs()
|
|||
// default real time buffer size was 3041280 (3M)
|
||||
args.Append("-rtbufsize 10M ");
|
||||
|
||||
string fps = isCustom ? "$fps$" : ScreenRecordFPS.ToString();
|
||||
|
||||
if (string.IsNullOrEmpty(FFmpeg.VideoSource) || FFmpeg.VideoSource.Equals(FFmpegHelper.GDIgrab, StringComparison.InvariantCultureIgnoreCase))
|
||||
{
|
||||
// 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);
|
||||
fps, CaptureArea.X, CaptureArea.Y, CaptureArea.Width, CaptureArea.Height, DrawCursor ? 1 : 0, 0);
|
||||
|
||||
if (FFmpeg.IsAudioSourceSelected())
|
||||
{
|
||||
|
@ -105,7 +103,7 @@ private string GetFFmpegArgs()
|
|||
}
|
||||
else
|
||||
{
|
||||
args.AppendFormat("-f dshow -framerate {0} -i video=\"{1}\"", ScreenRecordFPS, FFmpeg.VideoSource);
|
||||
args.AppendFormat("-f dshow -framerate {0} -i video=\"{1}\"", fps, FFmpeg.VideoSource);
|
||||
|
||||
if (FFmpeg.IsAudioSourceSelected())
|
||||
{
|
||||
|
@ -125,7 +123,7 @@ private string GetFFmpegArgs()
|
|||
args.AppendFormat("-c:v {0} ", FFmpeg.VideoCodec.ToString());
|
||||
|
||||
// output FPS
|
||||
args.AppendFormat("-r {0} ", ScreenRecordFPS);
|
||||
args.AppendFormat("-r {0} ", fps);
|
||||
|
||||
switch (FFmpeg.VideoCodec)
|
||||
{
|
||||
|
@ -164,10 +162,10 @@ private string GetFFmpegArgs()
|
|||
if (Duration > 0)
|
||||
{
|
||||
// duration limit
|
||||
args.AppendFormat("-t {0} ", Duration);
|
||||
args.AppendFormat("-t {0} ", isCustom ? "$duration$" : Duration.ToString("0.0", CultureInfo.InvariantCulture));
|
||||
}
|
||||
|
||||
args.AppendFormat("\"{0}\"", Path.ChangeExtension(OutputPath, FFmpeg.Extension));
|
||||
args.AppendFormat("\"{0}\"", isCustom ? "$output$" : Path.ChangeExtension(OutputPath, FFmpeg.Extension));
|
||||
|
||||
return args.ToString();
|
||||
}
|
||||
|
|
|
@ -181,13 +181,13 @@ public void StartRecording(TaskSettings TaskSettings)
|
|||
|
||||
ScreencastOptions options = new ScreencastOptions()
|
||||
{
|
||||
CaptureArea = captureRectangle,
|
||||
GIFFPS = TaskSettings.CaptureSettings.GIFFPS,
|
||||
ScreenRecordFPS = TaskSettings.CaptureSettings.ScreenRecordFPS,
|
||||
OutputPath = path,
|
||||
Duration = TaskSettings.CaptureSettings.ScreenRecordFixedDuration ? TaskSettings.CaptureSettings.ScreenRecordDuration : 0,
|
||||
AVI = TaskSettings.CaptureSettings.AVIOptions,
|
||||
FFmpeg = TaskSettings.CaptureSettings.FFmpegOptions,
|
||||
AVI = TaskSettings.CaptureSettings.AVIOptions,
|
||||
ScreenRecordFPS = TaskSettings.CaptureSettings.ScreenRecordFPS,
|
||||
GIFFPS = TaskSettings.CaptureSettings.GIFFPS,
|
||||
Duration = TaskSettings.CaptureSettings.ScreenRecordFixedDuration ? TaskSettings.CaptureSettings.ScreenRecordDuration : 0,
|
||||
OutputPath = path,
|
||||
CaptureArea = captureRectangle,
|
||||
DrawCursor = TaskSettings.CaptureSettings.ShowCursor
|
||||
};
|
||||
|
||||
|
|
30
ShareX/Forms/TaskSettingsForm.Designer.cs
generated
30
ShareX/Forms/TaskSettingsForm.Designer.cs
generated
|
@ -39,6 +39,7 @@ private void InitializeComponent()
|
|||
this.cmsTask = new System.Windows.Forms.ContextMenuStrip(this.components);
|
||||
this.tcHotkeySettings = new System.Windows.Forms.TabControl();
|
||||
this.tpTask = new System.Windows.Forms.TabPage();
|
||||
this.btnDescriptionAutoFill = new System.Windows.Forms.Button();
|
||||
this.chkOverrideFTP = new System.Windows.Forms.CheckBox();
|
||||
this.cboFTPaccounts = new System.Windows.Forms.ComboBox();
|
||||
this.btnAfterCapture = new HelpersLib.MenuButton();
|
||||
|
@ -166,7 +167,6 @@ private void InitializeComponent()
|
|||
this.tpAdvanced = new System.Windows.Forms.TabPage();
|
||||
this.pgTaskSettings = new System.Windows.Forms.PropertyGrid();
|
||||
this.chkUseDefaultAdvancedSettings = new System.Windows.Forms.CheckBox();
|
||||
this.btnDescriptionAutoFill = new System.Windows.Forms.Button();
|
||||
this.tcHotkeySettings.SuspendLayout();
|
||||
this.tpTask.SuspendLayout();
|
||||
this.cmsDestinations.SuspendLayout();
|
||||
|
@ -217,7 +217,7 @@ private void InitializeComponent()
|
|||
// cbUseDefaultAfterCaptureSettings
|
||||
//
|
||||
this.cbUseDefaultAfterCaptureSettings.AutoSize = true;
|
||||
this.cbUseDefaultAfterCaptureSettings.Location = new System.Drawing.Point(6, 70);
|
||||
this.cbUseDefaultAfterCaptureSettings.Location = new System.Drawing.Point(8, 70);
|
||||
this.cbUseDefaultAfterCaptureSettings.Name = "cbUseDefaultAfterCaptureSettings";
|
||||
this.cbUseDefaultAfterCaptureSettings.Size = new System.Drawing.Size(193, 17);
|
||||
this.cbUseDefaultAfterCaptureSettings.TabIndex = 3;
|
||||
|
@ -228,7 +228,7 @@ private void InitializeComponent()
|
|||
// cbUseDefaultAfterUploadSettings
|
||||
//
|
||||
this.cbUseDefaultAfterUploadSettings.AutoSize = true;
|
||||
this.cbUseDefaultAfterUploadSettings.Location = new System.Drawing.Point(6, 126);
|
||||
this.cbUseDefaultAfterUploadSettings.Location = new System.Drawing.Point(8, 126);
|
||||
this.cbUseDefaultAfterUploadSettings.Name = "cbUseDefaultAfterUploadSettings";
|
||||
this.cbUseDefaultAfterUploadSettings.Size = new System.Drawing.Size(189, 17);
|
||||
this.cbUseDefaultAfterUploadSettings.TabIndex = 5;
|
||||
|
@ -239,7 +239,7 @@ private void InitializeComponent()
|
|||
// cbUseDefaultDestinationSettings
|
||||
//
|
||||
this.cbUseDefaultDestinationSettings.AutoSize = true;
|
||||
this.cbUseDefaultDestinationSettings.Location = new System.Drawing.Point(6, 182);
|
||||
this.cbUseDefaultDestinationSettings.Location = new System.Drawing.Point(8, 182);
|
||||
this.cbUseDefaultDestinationSettings.Name = "cbUseDefaultDestinationSettings";
|
||||
this.cbUseDefaultDestinationSettings.Size = new System.Drawing.Size(185, 17);
|
||||
this.cbUseDefaultDestinationSettings.TabIndex = 7;
|
||||
|
@ -309,10 +309,20 @@ private void InitializeComponent()
|
|||
this.tpTask.Text = "Task";
|
||||
this.tpTask.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// btnDescriptionAutoFill
|
||||
//
|
||||
this.btnDescriptionAutoFill.Location = new System.Drawing.Point(448, 7);
|
||||
this.btnDescriptionAutoFill.Name = "btnDescriptionAutoFill";
|
||||
this.btnDescriptionAutoFill.Size = new System.Drawing.Size(64, 24);
|
||||
this.btnDescriptionAutoFill.TabIndex = 11;
|
||||
this.btnDescriptionAutoFill.Text = "Auto fill";
|
||||
this.btnDescriptionAutoFill.UseVisualStyleBackColor = true;
|
||||
this.btnDescriptionAutoFill.Click += new System.EventHandler(this.btnDescriptionAutoFill_Click);
|
||||
//
|
||||
// chkOverrideFTP
|
||||
//
|
||||
this.chkOverrideFTP.AutoSize = true;
|
||||
this.chkOverrideFTP.Location = new System.Drawing.Point(6, 240);
|
||||
this.chkOverrideFTP.Location = new System.Drawing.Point(8, 240);
|
||||
this.chkOverrideFTP.Name = "chkOverrideFTP";
|
||||
this.chkOverrideFTP.Size = new System.Drawing.Size(169, 17);
|
||||
this.chkOverrideFTP.TabIndex = 9;
|
||||
|
@ -1804,16 +1814,6 @@ private void InitializeComponent()
|
|||
this.chkUseDefaultAdvancedSettings.UseVisualStyleBackColor = true;
|
||||
this.chkUseDefaultAdvancedSettings.CheckedChanged += new System.EventHandler(this.chkUseDefaultAdvancedSettings_CheckedChanged);
|
||||
//
|
||||
// btnDescriptionAutoFill
|
||||
//
|
||||
this.btnDescriptionAutoFill.Location = new System.Drawing.Point(448, 7);
|
||||
this.btnDescriptionAutoFill.Name = "btnDescriptionAutoFill";
|
||||
this.btnDescriptionAutoFill.Size = new System.Drawing.Size(64, 24);
|
||||
this.btnDescriptionAutoFill.TabIndex = 11;
|
||||
this.btnDescriptionAutoFill.Text = "Auto fill";
|
||||
this.btnDescriptionAutoFill.UseVisualStyleBackColor = true;
|
||||
this.btnDescriptionAutoFill.Click += new System.EventHandler(this.btnDescriptionAutoFill_Click);
|
||||
//
|
||||
// TaskSettingsForm
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
|
|
|
@ -668,15 +668,16 @@ private void btnScreenRecorderOptions_Click(object sender, EventArgs e)
|
|||
{
|
||||
ScreencastOptions options = new ScreencastOptions
|
||||
{
|
||||
AVI = TaskSettings.CaptureSettings.AVIOptions,
|
||||
FFmpeg = TaskSettings.CaptureSettings.FFmpegOptions,
|
||||
AVI = TaskSettings.CaptureSettings.AVIOptions,
|
||||
ShowAVIOptionsDialog = true,
|
||||
GIFFPS = TaskSettings.CaptureSettings.GIFFPS,
|
||||
ScreenRecordFPS = TaskSettings.CaptureSettings.ScreenRecordFPS,
|
||||
GIFFPS = TaskSettings.CaptureSettings.GIFFPS,
|
||||
Duration = TaskSettings.CaptureSettings.ScreenRecordFixedDuration ? TaskSettings.CaptureSettings.ScreenRecordDuration : 0,
|
||||
OutputPath = "output.mp4",
|
||||
ParentWindow = this.Handle,
|
||||
CaptureArea = Screen.PrimaryScreen.Bounds,
|
||||
DrawCursor = true
|
||||
DrawCursor = TaskSettings.CaptureSettings.ShowCursor,
|
||||
ParentWindow = this.Handle
|
||||
};
|
||||
|
||||
switch (TaskSettings.CaptureSettings.ScreenRecordOutput)
|
||||
|
|
Loading…
Reference in a new issue