Progress bar is now correct when using FPS limiting

This commit is contained in:
N00MKRAD 2023-12-21 05:51:28 +01:00
parent 4576f37ce7
commit 829b37ca6a
4 changed files with 22 additions and 10 deletions

View File

@ -7,10 +7,6 @@ using System.Threading.Tasks;
using System.Threading;
using Flowframes.IO;
using ImageMagick;
using Flowframes.Os;
using Flowframes.Data;
using System.Drawing;
using Paths = Flowframes.IO.Paths;
using Newtonsoft.Json;
namespace Flowframes.Magick
@ -117,7 +113,7 @@ namespace Flowframes.Magick
}
}
System.Threading.Interlocked.Increment(ref statsFramesDeleted);
Interlocked.Increment(ref statsFramesDeleted);
if (j+1 == framePaths.Length)
return;
@ -126,7 +122,7 @@ namespace Flowframes.Magick
}
System.Threading.Interlocked.Increment(ref statsFramesKept);
Interlocked.Increment(ref statsFramesKept);
// this frame is different, stop testing agaisnt 'i'
// all the frames between i and j are dupes, we can skip them
@ -206,8 +202,14 @@ namespace Flowframes.Magick
Logger.Log($"[Deduplication]{testStr} Done. Kept {framesLeft} ({keptPercent}) frames, deleted {framesDeleted} frames.", false, true);
if (statsFramesKept <= 0)
Interpolate.Cancel("No frames were left after de-duplication!\n\nTry decreasing the de-duplication threshold.");
}
{
Interpolate.Cancel("No frames were left after de-duplication!\n\nTry decreasing the de-duplication threshold.");
}
else
{
// Interpolate.InterpProgressMultiplier = (framePaths.Length / (float)framesLeft);
}
}
static float GetDifference(MagickImage img1, MagickImage img2)
{
double err = img1.Compare(img2, ErrorMetric.Fuzz);

View File

@ -26,6 +26,7 @@ namespace Flowframes
public static InterpSettings currentSettings;
public static MediaFile currentMediaFile;
public static bool canceled = false;
public static float InterpProgressMultiplier = 1f;
static Stopwatch sw = new Stopwatch();
public static async Task Start()
@ -149,6 +150,8 @@ namespace Flowframes
Logger.Log($"Deduplication: Kept {framesLeft} frames.");
else
Logger.Log($"Deduplication: Kept {framesLeft} ({keptPercent}) frames, deleted {framesDeleted} frames.");
// InterpProgressMultiplier = (currentMediaFile.FrameCount / (float)framesLeft);
}
if (!Config.GetBool("allowConsecutiveSceneChanges", true))

View File

@ -117,7 +117,7 @@ namespace Flowframes.Main
}
string fpsLimitValue = Config.Get(Config.Key.maxFps);
float fpsLimit = (fpsLimitValue.Contains("/") ? new Fraction(Config.Get(Config.Key.maxFps)).GetFloat() : fpsLimitValue.GetFloat());
float fpsLimit = (fpsLimitValue.Contains("/") ? new Fraction(fpsLimitValue).GetFloat() : fpsLimitValue.GetFloat());
int maxFps = s.outSettings.Encoder.GetInfo().MaxFramerate;
if (passes && s.outFps.GetFloat() < 1f || (s.outFps.GetFloat() > maxFps && !(fpsLimit > 0 && fpsLimit <= maxFps)))
@ -127,6 +127,13 @@ namespace Flowframes.Main
passes = false;
}
float fpsLimitFloat = fpsLimitValue.GetFloat();
if (fpsLimitFloat > 0)
Interpolate.InterpProgressMultiplier = s.outFps.GetFloat() / fpsLimitFloat;
else
Interpolate.InterpProgressMultiplier = 1f;
if (!passes)
I.Cancel("Invalid settings detected.", true);

View File

@ -135,7 +135,7 @@ namespace Flowframes.Ui
interpolatedInputFramesCount = ((frames / I.currentSettings.interpFactor).RoundToInt() - 1);
//ResumeUtils.Save();
frames = frames.Clamp(0, target);
int percent = (int)Math.Round(((float)frames / target) * 100f);
int percent = (int)Math.Round(((float)frames / target) * 100f * Interpolate.InterpProgressMultiplier);
Program.mainForm.SetProgress(percent);
float generousTime = ((AiProcess.processTime.ElapsedMilliseconds - AiProcess.lastStartupTimeMs) / 1000f);