Target FPS input: Re-calculate using rounded factor after entering value

This commit is contained in:
n00mkrad
2022-04-22 09:23:31 +02:00
parent 3e41b05b28
commit 9f648aec64
4 changed files with 58 additions and 33 deletions

View File

@@ -261,7 +261,7 @@
//
this.label6.AutoSize = true;
this.label6.ForeColor = System.Drawing.Color.White;
this.label6.Location = new System.Drawing.Point(443, 100);
this.label6.Location = new System.Drawing.Point(450, 100);
this.label6.Margin = new System.Windows.Forms.Padding(3, 0, 0, 0);
this.label6.Name = "label6";
this.label6.Size = new System.Drawing.Size(15, 15);
@@ -272,11 +272,11 @@
//
this.fpsOutTbox.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(64)))), ((int)(((byte)(64)))), ((int)(((byte)(64)))));
this.fpsOutTbox.ForeColor = System.Drawing.Color.White;
this.fpsOutTbox.Location = new System.Drawing.Point(461, 97);
this.fpsOutTbox.Location = new System.Drawing.Point(468, 97);
this.fpsOutTbox.MinimumSize = new System.Drawing.Size(4, 21);
this.fpsOutTbox.Name = "fpsOutTbox";
this.fpsOutTbox.ReadOnly = true;
this.fpsOutTbox.Size = new System.Drawing.Size(107, 23);
this.fpsOutTbox.Size = new System.Drawing.Size(100, 23);
this.fpsOutTbox.TabIndex = 9;
this.fpsOutTbox.Leave += new System.EventHandler(this.fpsOutTbox_Leave);
//
@@ -302,7 +302,7 @@
this.interpFactorCombox.FormattingEnabled = true;
this.interpFactorCombox.Location = new System.Drawing.Point(387, 97);
this.interpFactorCombox.Name = "interpFactorCombox";
this.interpFactorCombox.Size = new System.Drawing.Size(50, 23);
this.interpFactorCombox.Size = new System.Drawing.Size(57, 23);
this.interpFactorCombox.TabIndex = 7;
this.interpFactorCombox.SelectedIndexChanged += new System.EventHandler(this.interpFactorCombox_SelectedIndexChanged);
this.interpFactorCombox.TextUpdate += new System.EventHandler(this.interpFactorCombox_SelectedIndexChanged);

View File

@@ -724,13 +724,10 @@ namespace Flowframes
{
float inFps = fpsInTbox.GetFloat();
float outFps = fpsOutTbox.GetFloat();
var targetFactorRounded = Math.Round((Decimal)(outFps / inFps), 2, MidpointRounding.AwayFromZero);
var targetFactorRounded = Math.Round((Decimal)(outFps / inFps), 3, MidpointRounding.AwayFromZero);
interpFactorCombox.Text = $"{targetFactorRounded}";
fpsOutTbox.Text = $"{outFps} FPS";
ValidateFactor();
fpsOutTbox.Text = $"{inFps * interpFactorCombox.GetFloat()} FPS";
}
}
}

View File

@@ -25,7 +25,7 @@ namespace Flowframes.Os
public static int lastStartupTimeMs = 1000;
static string lastInPath;
public static void Kill ()
public static void Kill()
{
if (lastAiProcess == null) return;
@@ -40,7 +40,7 @@ namespace Flowframes.Os
}
}
static void AiStarted (Process proc, int startupTimeMs, string inPath = "")
static void AiStarted(Process proc, int startupTimeMs, string inPath = "")
{
lastStartupTimeMs = startupTimeMs;
processTime.Restart();
@@ -82,7 +82,7 @@ namespace Flowframes.Os
Logger.Log(logStr);
processTime.Stop();
if(interpFramesCount < 3)
if (interpFramesCount < 3)
{
string[] logLines = File.ReadAllLines(Path.Combine(Paths.GetLogPath(), lastLogName + ".txt"));
string log = string.Join("\n", logLines.Reverse().Take(10).Reverse().Select(x => x.Split("]: ").Last()).ToList());
@@ -97,10 +97,8 @@ namespace Flowframes.Os
{
if (AvProcess.lastAvProcess != null && !AvProcess.lastAvProcess.HasExited)
{
string lastLine = Logger.LastLogLine;
if(lastLine.Contains("frame"))
Logger.Log(FormatUtils.BeautifyFfmpegStats(lastLine), false, Logger.LastUiLine.ToLower().Contains("frame"));
if (Logger.LastLogLine.ToLower().Contains("frame: "))
Logger.Log(FormatUtils.BeautifyFfmpegStats(Logger.LastLogLine), false, Logger.LastUiLine.ToLower().Contains("frame"));
}
if (AvProcess.lastAvProcess.HasExited && !AutoEncode.HasWorkToDo()) // Stop logging if ffmpeg is not running & AE is done
@@ -109,7 +107,7 @@ namespace Flowframes.Os
await Task.Delay(500);
}
}
catch(Exception e)
catch (Exception e)
{
Logger.Log($"AiFinished encoder logging error: {e.Message}\n{e.StackTrace}", true);
}
@@ -117,7 +115,7 @@ namespace Flowframes.Os
public static async Task RunRifeCuda(string framesPath, float interpFactor, string mdl)
{
if(Interpolate.currentlyUsingAutoEnc) // Ensure AutoEnc is not paused
if (Interpolate.currentlyUsingAutoEnc) // Ensure AutoEnc is not paused
AutoEncode.paused = false;
try
@@ -146,12 +144,13 @@ namespace Flowframes.Os
catch (Exception e)
{
Logger.Log("Error running RIFE-CUDA: " + e.Message);
Logger.Log("Stack Trace: " + e.StackTrace, true);
}
await AiFinished("RIFE");
}
public static async Task RunRifeCudaProcess (string inPath, string outDir, string script, float interpFactor, string mdl)
public static async Task RunRifeCudaProcess(string inPath, string outDir, string script, float interpFactor, string mdl)
{
string outPath = Path.Combine(inPath.GetParentDir(), outDir);
Directory.CreateDirectory(outPath);
@@ -208,6 +207,7 @@ namespace Flowframes.Os
catch (Exception e)
{
Logger.Log("Error running FLAVR-CUDA: " + e.Message);
Logger.Log("Stack Trace: " + e.StackTrace, true);
}
await AiFinished("FLAVR");
@@ -244,7 +244,7 @@ namespace Flowframes.Os
while (!flavrPy.HasExited) await Task.Delay(1);
}
public static async Task RunRifeNcnn (string framesPath, string outPath, float factor, string mdl)
public static async Task RunRifeNcnn(string framesPath, string outPath, float factor, string mdl)
{
processTimeMulti.Restart();
@@ -259,6 +259,7 @@ namespace Flowframes.Os
catch (Exception e)
{
Logger.Log("Error running RIFE-NCNN: " + e.Message);
Logger.Log("Stack Trace: " + e.StackTrace, true);
}
await AiFinished("RIFE");
@@ -311,12 +312,13 @@ namespace Flowframes.Os
catch (Exception e)
{
Logger.Log("Error running DAIN-NCNN: " + e.Message);
Logger.Log("Stack Trace: " + e.StackTrace, true);
}
await AiFinished("DAIN");
}
public static async Task RunDainNcnnProcess (string framesPath, string outPath, float factor, string mdl, int tilesize)
public static async Task RunDainNcnnProcess(string framesPath, string outPath, float factor, string mdl, int tilesize)
{
string dainDir = Path.Combine(Paths.GetPkgPath(), Implementations.dainNcnn.pkgDir);
Directory.CreateDirectory(outPath);
@@ -371,6 +373,7 @@ namespace Flowframes.Os
catch (Exception e)
{
Logger.Log("Error running XVFI-CUDA: " + e.Message);
Logger.Log("Stack Trace: " + e.StackTrace, true);
}
await AiFinished("XVFI");
@@ -411,7 +414,7 @@ namespace Flowframes.Os
while (!xvfiPy.HasExited) await Task.Delay(1);
}
static void LogOutput (string line, string logFilename, bool err = false)
static void LogOutput(string line, string logFilename, bool err = false)
{
if (string.IsNullOrWhiteSpace(line) || line.Length < 6)
return;
@@ -519,7 +522,7 @@ namespace Flowframes.Os
InterpolationProgress.UpdateLastFrameFromInterpOutput(line);
}
static string GetNcnnPattern ()
static string GetNcnnPattern()
{
return $"%0{Padding.interpFrames}d{Interpolate.current.interpExt}";
}
@@ -535,7 +538,7 @@ namespace Flowframes.Os
return tilesizeStr;
}
static string GetNcnnThreads ()
static string GetNcnnThreads(bool forceSingleThread = false)
{
int gpusAmount = Config.Get(Config.Key.ncnnGpus).Split(',').Length;
int procThreads = Config.GetInt(Config.Key.ncnnThreads);
@@ -544,14 +547,39 @@ namespace Flowframes.Os
for (int i = 1; i < gpusAmount; i++)
progThreadsStr += $",{procThreads}";
return $"4:{progThreadsStr}:4"; ;
return $"{(forceSingleThread ? 1 : (Interpolate.currentlyUsingAutoEnc ? 2 : 4))}:{progThreadsStr}:4"; // Read threads: 1 for singlethreaded, 2 for autoenc, 4 if order is irrelevant
}
static async Task DeleteNcnnDupes (string dir, float factor)
static async Task DeleteNcnnDupes(string dir, float factor)
{
int dupeCount = InterpolateUtils.GetRoundedInterpFramesPerInputFrame(factor);
Logger.Log($"DeleteNcnnDupes: Calculated dupe count from factor; deleting last {dupeCount} interp frames ({IoUtils.GetAmountOfFiles(dir, false)} files)", true);
IoUtils.GetFileInfosSorted(dir, false).Reverse().Take(dupeCount).ToList().ForEach(x => x.Delete());
var files = IoUtils.GetFileInfosSorted(dir, false).Reverse().Take(dupeCount).ToList();
Logger.Log($"DeleteNcnnDupes: Calculated dupe count from factor; deleting last {dupeCount} interp frames of {IoUtils.GetAmountOfFiles(dir, false)} ({string.Join(", ", files.Select(x => x.Name))})", true);
int attempts = 4;
while (attempts > 0)
{
try
{
files.ForEach(x => x.Delete());
break;
}
catch (Exception ex)
{
attempts--;
if (attempts < 1)
{
Logger.Log($"DeleteNcnnDupes Error: {ex.Message}", true);
break;
}
else
{
await Task.Delay(500);
}
}
}
}
static double Compare(string referenceImg, string compareImg)