mirror of
https://github.com/n00mkrad/flowframes.git
synced 2025-12-16 16:37:48 +01:00
Basic CLI/batch support
-start - Auto-start interpolation if file was also given -quit-when-done - Auto-quit after task or queue -factor - Interpolation factor (2/4/8) -ai - Interpolation AI by dropdown index -output-mode - Export mode by dropdown index -model - AI model by dropdown index
This commit is contained in:
@@ -53,7 +53,7 @@ namespace Flowframes
|
||||
RemovePreviewIfDisabled();
|
||||
UpdateStepByStepControls();
|
||||
Initialized();
|
||||
HandleFileArgs();
|
||||
HandleArgs();
|
||||
Text = $"Flowframes";
|
||||
|
||||
if (Program.args.Contains("show-model-downloader"))
|
||||
@@ -90,24 +90,31 @@ namespace Flowframes
|
||||
}
|
||||
}
|
||||
|
||||
void HandleFileArgs()
|
||||
void HandleArgs()
|
||||
{
|
||||
try
|
||||
foreach(string arg in Program.args)
|
||||
{
|
||||
List<string> files = new List<string>();
|
||||
|
||||
foreach (string arg in Program.args)
|
||||
if (Path.GetExtension(arg) != ".exe" && IOUtils.IsFileValid(arg))
|
||||
files.Add(arg);
|
||||
|
||||
if(files.Count > 0)
|
||||
DragDropHandler(files.ToArray());
|
||||
if (arg.StartsWith("factor="))
|
||||
{
|
||||
int factor = arg.Split('=').Last().GetInt();
|
||||
if (factor == 2) interpFactorCombox.SelectedIndex = 0;
|
||||
if (factor == 4) interpFactorCombox.SelectedIndex = 1;
|
||||
if (factor == 8) interpFactorCombox.SelectedIndex = 2;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Logger.Log($"Failed to load input from given launch arguments.", true);
|
||||
Logger.Log($"{e.Message}\n{e.StackTrace}", true);
|
||||
|
||||
if (arg.StartsWith("ai="))
|
||||
aiCombox.SelectedIndex = arg.Split('=').Last().GetInt();
|
||||
|
||||
if (arg.StartsWith("model="))
|
||||
aiModel.SelectedIndex = arg.Split('=').Last().GetInt();
|
||||
|
||||
if (arg.StartsWith("output-mode="))
|
||||
outModeCombox.SelectedIndex = arg.Split('=').Last().GetInt();
|
||||
}
|
||||
|
||||
if (Program.fileArgs.Length > 0)
|
||||
DragDropHandler(Program.fileArgs.Where(x => IOUtils.IsFileValid(x)).ToArray());
|
||||
|
||||
}
|
||||
|
||||
void RemovePreviewIfDisabled ()
|
||||
@@ -223,6 +230,9 @@ namespace Flowframes
|
||||
|
||||
public void CompletionAction ()
|
||||
{
|
||||
if (Program.args.Contains("quit-when-done"))
|
||||
Application.Exit();
|
||||
|
||||
if (completionAction.SelectedIndex == 1)
|
||||
new TimeoutForm(completionAction.Text, Application.Exit).ShowDialog();
|
||||
|
||||
@@ -457,11 +467,13 @@ namespace Flowframes
|
||||
{
|
||||
if (Program.busy) return;
|
||||
|
||||
bool start = Program.initialRun && Program.args.Contains("start");
|
||||
|
||||
if (files.Length > 1)
|
||||
{
|
||||
queueBtn_Click(null, null);
|
||||
if (BatchProcessing.currentBatchForm != null)
|
||||
BatchProcessing.currentBatchForm.LoadDroppedPaths(files);
|
||||
BatchProcessing.currentBatchForm.LoadDroppedPaths(files, start);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -477,7 +489,7 @@ namespace Flowframes
|
||||
|
||||
trimCombox.SelectedIndex = 0;
|
||||
|
||||
MainUiFunctions.InitInput(outputTbox, inputTbox, fpsInTbox);
|
||||
MainUiFunctions.InitInput(outputTbox, inputTbox, fpsInTbox, start);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -115,7 +115,7 @@ namespace Flowframes.Forms
|
||||
await LoadDroppedPaths(droppedPaths);
|
||||
}
|
||||
|
||||
public async Task LoadDroppedPaths (string[] droppedPaths)
|
||||
public async Task LoadDroppedPaths (string[] droppedPaths, bool start = false)
|
||||
{
|
||||
foreach (string path in droppedPaths)
|
||||
{
|
||||
@@ -131,6 +131,9 @@ namespace Flowframes.Forms
|
||||
Program.batchQueue.Enqueue(current);
|
||||
RefreshGui();
|
||||
}
|
||||
|
||||
if (start)
|
||||
runBtn_Click(null, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
13
Code/Forms/DebugForm.Designer.cs
generated
13
Code/Forms/DebugForm.Designer.cs
generated
@@ -101,6 +101,9 @@ namespace Flowframes.Forms
|
||||
//
|
||||
// panel1
|
||||
//
|
||||
this.panel1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
|
||||
| System.Windows.Forms.AnchorStyles.Left)
|
||||
| System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.panel1.Controls.Add(this.configDataGrid);
|
||||
this.panel1.Location = new System.Drawing.Point(6, 80);
|
||||
this.panel1.Name = "panel1";
|
||||
@@ -111,11 +114,13 @@ namespace Flowframes.Forms
|
||||
//
|
||||
this.configDataGrid.AllowUserToResizeColumns = false;
|
||||
this.configDataGrid.AllowUserToResizeRows = false;
|
||||
this.configDataGrid.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
|
||||
| System.Windows.Forms.AnchorStyles.Left)
|
||||
| System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.configDataGrid.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.AllCells;
|
||||
this.configDataGrid.AutoSizeRowsMode = System.Windows.Forms.DataGridViewAutoSizeRowsMode.AllCells;
|
||||
this.configDataGrid.ClipboardCopyMode = System.Windows.Forms.DataGridViewClipboardCopyMode.EnableWithoutHeaderText;
|
||||
this.configDataGrid.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||
this.configDataGrid.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.configDataGrid.Location = new System.Drawing.Point(0, 0);
|
||||
this.configDataGrid.MultiSelect = false;
|
||||
this.configDataGrid.Name = "configDataGrid";
|
||||
@@ -251,6 +256,9 @@ namespace Flowframes.Forms
|
||||
//
|
||||
// logBox
|
||||
//
|
||||
this.logBox.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
|
||||
| System.Windows.Forms.AnchorStyles.Left)
|
||||
| System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.logBox.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(64)))), ((int)(((byte)(64)))), ((int)(((byte)(64)))));
|
||||
this.logBox.Cursor = System.Windows.Forms.Cursors.Arrow;
|
||||
this.logBox.Font = new System.Drawing.Font("Consolas", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
|
||||
@@ -269,6 +277,9 @@ namespace Flowframes.Forms
|
||||
// htTabControl1
|
||||
//
|
||||
this.htTabControl1.AllowDrop = true;
|
||||
this.htTabControl1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
|
||||
| System.Windows.Forms.AnchorStyles.Left)
|
||||
| System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.htTabControl1.BackgroundColor = System.Drawing.Color.FromArgb(((int)(((byte)(45)))), ((int)(((byte)(45)))), ((int)(((byte)(48)))));
|
||||
this.htTabControl1.BorderTabLineColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(122)))), ((int)(((byte)(204)))));
|
||||
this.htTabControl1.Controls.Add(this.tabPage1);
|
||||
|
||||
@@ -126,6 +126,9 @@ To delete an entry, select the line by clicking on the left part, then press DEL
|
||||
<metadata name="toolTip.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>17, 17</value>
|
||||
</metadata>
|
||||
<metadata name="toolTip.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>17, 17</value>
|
||||
</metadata>
|
||||
<assembly alias="System.Drawing" name="System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
|
||||
<data name="$this.Icon" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>
|
||||
|
||||
@@ -34,6 +34,7 @@ namespace Flowframes
|
||||
{
|
||||
if (!BatchProcessing.busy && Program.busy) return;
|
||||
canceled = false;
|
||||
Program.initialRun = false;
|
||||
Program.mainForm.SetWorking(true);
|
||||
if (!Utils.InputIsValid(current.inPath, current.outPath, current.outFps, current.interpFactor, current.outMode)) return; // General input checks
|
||||
if (!Utils.CheckAiAvailable(current.ai)) return; // Check if selected AI pkg is installed
|
||||
|
||||
@@ -5,6 +5,7 @@ using Flowframes.MiscUtils;
|
||||
using Flowframes.OS;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Threading;
|
||||
@@ -17,7 +18,9 @@ namespace Flowframes
|
||||
{
|
||||
static class Program
|
||||
{
|
||||
public static string[] fileArgs = new string[0];
|
||||
public static string[] args = new string[0];
|
||||
public static bool initialRun = true;
|
||||
public static Form1 mainForm;
|
||||
|
||||
public static bool busy = false;
|
||||
@@ -40,8 +43,11 @@ namespace Flowframes
|
||||
|
||||
Networks.Init();
|
||||
Task.Run(() => DiskSpaceCheckLoop());
|
||||
fileArgs = Environment.GetCommandLineArgs().Where(a => a[0] != '-' && File.Exists(a)).ToList().Skip(1).ToArray();
|
||||
args = Environment.GetCommandLineArgs().Where(a => a[0] == '-').Select(x => x.Trim().Substring(1).ToLowerInvariant()).ToArray();
|
||||
Logger.Log($"Args: {(args.Length > 0 ? string.Join(", -", args) : "None")}", false);
|
||||
Logger.Log($"Command Line: {Environment.CommandLine}", true);
|
||||
Logger.Log($"Files: {(fileArgs.Length > 0 ? string.Join(", ", fileArgs) : "None")}", true);
|
||||
Logger.Log($"Args: {(args.Length > 0 ? string.Join(", ", args) : "None")}", true);
|
||||
|
||||
LaunchMainForm();
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@ namespace Flowframes.UI
|
||||
{
|
||||
class MainUiFunctions
|
||||
{
|
||||
public static async Task InitInput (TextBox outputTbox, TextBox inputTbox, TextBox fpsInTbox)
|
||||
public static async Task InitInput (TextBox outputTbox, TextBox inputTbox, TextBox fpsInTbox, bool start = false)
|
||||
{
|
||||
Program.mainForm.SetTab("interpolate");
|
||||
Program.mainForm.ResetInputInfo();
|
||||
@@ -60,6 +60,10 @@ namespace Flowframes.UI
|
||||
Dedupe.ClearCache();
|
||||
await Task.Delay(10);
|
||||
InterpolationProgress.SetPreviewImg(await GetThumbnail(path));
|
||||
|
||||
if (start)
|
||||
Program.mainForm.runBtn_Click(null, null);
|
||||
|
||||
}
|
||||
|
||||
static void CheckExistingFolder (string inpath, string outpath)
|
||||
|
||||
Reference in New Issue
Block a user