Batch Processing fixes and improvements

This commit is contained in:
N00MKRAD
2021-05-30 15:03:24 +02:00
parent c53bf9166f
commit 2fda79aad7
6 changed files with 48 additions and 37 deletions

View File

@@ -78,7 +78,7 @@
this.runBtn.ForeColor = System.Drawing.Color.White;
this.runBtn.Location = new System.Drawing.Point(682, 443);
this.runBtn.Name = "runBtn";
this.runBtn.Size = new System.Drawing.Size(250, 40);
this.runBtn.Size = new System.Drawing.Size(250, 42);
this.runBtn.TabIndex = 36;
this.runBtn.Text = "Start";
this.runBtn.UseVisualStyleBackColor = false;
@@ -132,13 +132,13 @@
//
this.taskList.AllowDrop = true;
this.taskList.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(48)))), ((int)(((byte)(48)))), ((int)(((byte)(48)))));
this.taskList.Font = new System.Drawing.Font("Microsoft Sans Serif", 11.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.taskList.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.taskList.ForeColor = System.Drawing.Color.White;
this.taskList.FormattingEnabled = true;
this.taskList.ItemHeight = 18;
this.taskList.ItemHeight = 16;
this.taskList.Location = new System.Drawing.Point(12, 65);
this.taskList.Name = "taskList";
this.taskList.Size = new System.Drawing.Size(664, 418);
this.taskList.Size = new System.Drawing.Size(664, 420);
this.taskList.TabIndex = 43;
this.taskList.SelectedIndexChanged += new System.EventHandler(this.taskList_SelectedIndexChanged);
this.taskList.DragDrop += new System.Windows.Forms.DragEventHandler(this.taskList_DragDrop);

View File

@@ -1,7 +1,6 @@
using Flowframes.IO;
using Flowframes.Main;
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
@@ -29,12 +28,13 @@ namespace Flowframes.Forms
public void RefreshGui ()
{
taskList.Items.Clear();
string nl = Environment.NewLine;
for (int i = 0; i < Program.batchQueue.Count; i++)
{
InterpSettings entry = Program.batchQueue.ElementAt(i);
string niceOutMode = entry.outMode.ToString().ToUpper().Replace("VID", "").Replace("IMG", "");
string str = $"#{i}: {Path.GetFileName(entry.inPath).Trunc(45)} - {entry.inFps} FPS => {entry.interpFactor}x{nl} {entry.ai.aiNameShort} => {niceOutMode}";
string niceOutMode = entry.outMode.ToString().ToUpper().Remove("VID").Remove("IMG");
string str = $"#{i}: {Path.GetFileName(entry.inPath).Trunc(40)} - {entry.inFps.GetFloat()} FPS => " +
$"{entry.interpFactor}x {entry.ai.aiNameShort} ({entry.model.name}) => {niceOutMode}";
taskList.Items.Add(str);
}
}
@@ -58,7 +58,6 @@ namespace Flowframes.Forms
{
stopBtn.Enabled = true;
BatchProcessing.Start();
//WindowState = FormWindowState.Minimized;
Program.mainForm.WindowState = FormWindowState.Normal;
Program.mainForm.BringToFront();
}
@@ -120,33 +119,18 @@ namespace Flowframes.Forms
{
foreach (string path in droppedPaths)
{
Logger.Log($"Dropped file: '{path}'", true);
string frame1 = Path.Combine(path, "00000001.png");
if (IOUtils.IsPathDirectory(path) && !File.Exists(frame1))
{
InterpolateUtils.ShowMessage($"Can't find frames in this folder:\n\n{frame1} does not exist.", "Error");
continue;
}
Logger.Log($"BatchForm: Dropped path: '{path}'", true);
InterpSettings current = Program.mainForm.GetCurrentSettings();
current.UpdatePaths(path, path.GetParentDir());
current.inFps = (await GetFramerate(path));
current.inFpsDetected = await IOUtils.GetFpsFolderOrVideo(path);
current.inFps = current.inFpsDetected;
current.outFps = current.inFps * current.interpFactor;
Program.batchQueue.Enqueue(current);
RefreshGui();
await Task.Delay(100);
}
}
async Task<Fraction> GetFramerate (string path)
{
Fraction fps = (Interpolate.current != null) ? Interpolate.current.inFps : new Fraction();
Fraction fpsFromFile = await IOUtils.GetFpsFolderOrVideo(path);
if (fpsFromFile.GetFloat() > 0)
return fpsFromFile;
return fps;
}
}
}

View File

@@ -21,7 +21,6 @@ namespace Flowframes.Main
public static ModelCollection.ModelInfo GetModelByName(AI ai, string modelName)
{
Logger.Log($"looking for model '{modelName}'");
ModelCollection modelCollection = GetModels(ai);
foreach(ModelCollection.ModelInfo model in modelCollection.models)
@@ -32,5 +31,18 @@ namespace Flowframes.Main
return null;
}
public static ModelCollection.ModelInfo GetModelByDir(AI ai, string dirName)
{
ModelCollection modelCollection = GetModels(ai);
foreach (ModelCollection.ModelInfo model in modelCollection.models)
{
if (model.dir == dirName)
return model;
}
return null;
}
}
}

View File

@@ -29,10 +29,18 @@ namespace Flowframes.Main
{
if (!stopped && Program.batchQueue.Count > 0)
{
Logger.Log($"[Queue] Running queue task {i + 1}/{initTaskCount}, {Program.batchQueue.Count} tasks left.");
await RunEntry(Program.batchQueue.Peek());
if (currentBatchForm != null)
currentBatchForm.RefreshGui();
try
{
Logger.Log($"[Queue] Running queue task {i + 1}/{initTaskCount}, {Program.batchQueue.Count} tasks left.");
await RunEntry(Program.batchQueue.Peek());
if (currentBatchForm != null)
currentBatchForm.RefreshGui();
}
catch (Exception e)
{
Logger.Log($"Failed to run batch queue entry. If this happened after force stopping the queue, it's non-critical. {e.Message}", true);
}
}
await Task.Delay(1000);
}
@@ -55,6 +63,8 @@ namespace Flowframes.Main
return;
}
Logger.Log($"ENTRY DET FPS: " + entry.inFpsDetected);
string fname = Path.GetFileName(entry.inPath);
if (IOUtils.IsPathDirectory(entry.inPath)) fname = Path.GetDirectoryName(entry.inPath);
Logger.Log($"[Queue] Processing {fname} ({entry.interpFactor}x {entry.ai.aiNameShort}).");

View File

@@ -109,6 +109,7 @@ namespace Flowframes
if (entry.Contains(" fps") && !entry.Contains("Input ")) // Avoid reading FPS from the filename, in case filename contains "fps"
{
string num = entry.Replace(" fps", "").Trim().Replace(",", ".");
Logger.Log($"Float FPS from ffmpeg: {num.GetFloat()}", true, false, "ffmpeg");
ffmpegFps = new Fraction(num.GetFloat());
}
}
@@ -118,10 +119,14 @@ namespace Flowframes
Logger.Log("GetFramerate ffmpeg Error: " + ffmpegEx.Message, true, false);
}
if(preferFfmpeg)
Logger.Log($"ffmpegFps.GetFloat() = {ffmpegFps.GetFloat()}", true, false, "ffmpeg");
if (preferFfmpeg)
{
Logger.Log($"preferring ffmpeg");
if (ffmpegFps.GetFloat() > 0)
return ffmpegFps;
{ Logger.Log($"returning {ffmpegFps}"); return ffmpegFps; }
else
return ffprobeFps;
}

View File

@@ -75,7 +75,7 @@ namespace Flowframes.Media
public static async Task VideoToFrames(string inputFile, string framesDir, bool alpha, Fraction rate, bool deDupe, bool delSrc, Size size, string format)
{
Logger.Log("Extracting video frames from input video...");
Logger.Log($"VideoToFrames() - Alpha: {alpha} - Size: {size}", true, false, "ffmpeg");
Logger.Log($"VideoToFrames() - Alpha: {alpha} - Rate: {rate} - Size: {size} - Format: {format}", true, false, "ffmpeg");
string sizeStr = (size.Width > 1 && size.Height > 1) ? $"-s {size.Width}x{size.Height}" : "";
IOUtils.CreateDir(framesDir);
string mpStr = deDupe ? ((Config.GetInt(Config.Key.mpdecimateMode) == 0) ? mpDecDef : mpDecAggr) : "";