Fix incorrect output framerate calculation

This commit is contained in:
n00mkrad
2021-09-28 17:45:36 +02:00
parent e42e7305c7
commit f52f48090d
3 changed files with 8 additions and 8 deletions

View File

@@ -36,7 +36,7 @@ namespace Flowframes
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.InputIsValid(current.inPath, current.outPath, current.inFps, current.interpFactor, current.outMode)) return; // General input checks
if (!Utils.CheckAiAvailable(current.ai, current.model)) return; // Check if selected AI pkg is installed
if (!ResumeUtils.resumeNextRun && !Utils.CheckDeleteOldTempFolder()) return; // Try to delete temp folder if an old one exists
if (!Utils.CheckPathValid(current.inPath)) return; // Check if input path/file is valid

View File

@@ -33,7 +33,7 @@ namespace Flowframes.Main
current.RefreshAlpha();
current.stepByStep = true;
if (!InterpolateUtils.InputIsValid(current.inPath, current.outPath, current.outFps, current.interpFactor, current.outMode)) return; // General input checks
if (!InterpolateUtils.InputIsValid(current.inPath, current.outPath, current.inFps, current.interpFactor, current.outMode)) return; // General input checks
if (!InterpolateUtils.CheckPathValid(current.inPath)) return; // Check if input path/file is valid
if (step.Contains("Extract Frames"))

View File

@@ -94,13 +94,13 @@ namespace Flowframes.Main
return Path.Combine(basePath, Path.GetFileNameWithoutExtension(inPath).StripBadChars().Remove(" ").Trunc(30, false) + "-temp");
}
public static bool InputIsValid(string inDir, string outDir, Fraction fpsOut, float factor, I.OutMode outMode)
public static bool InputIsValid(string inDir, string outDir, Fraction fpsIn, float factor, I.OutMode outMode)
{
try
{
bool passes = true;
bool isFile = !IoUtils.IsPathDirectory(inDir);
float fpsOut = fpsIn.GetFloat() * factor;
if ((passes && isFile && !IoUtils.IsFileValid(inDir)) || (!isFile && !IoUtils.IsDirValid(inDir)))
{
@@ -114,18 +114,18 @@ namespace Flowframes.Main
passes = false;
}
if (passes && fpsOut.GetFloat() < 1f || fpsOut.GetFloat() > 1000f)
if (passes && fpsOut < 1f || fpsOut > 1000f)
{
string imgSeqNote = isFile ? "" : "\n\nWhen using an image sequence as input, you always have to specify the frame rate manually.";
ShowMessage($"Invalid output frame rate ({fpsOut.GetFloat()}).\nMust be 1-1000.{imgSeqNote}");
ShowMessage($"Invalid output frame rate ({fpsOut}).\nMust be 1-1000.{imgSeqNote}");
passes = false;
}
string fpsLimitValue = Config.Get(Config.Key.maxFps);
float fpsLimit = (fpsLimitValue.Contains("/") ? new Fraction(Config.Get(Config.Key.maxFps)).GetFloat() : fpsLimitValue.GetFloat());
if (outMode == I.OutMode.VidGif && fpsOut.GetFloat() > 50 && !(fpsLimit > 0 && fpsLimit <= 50))
Logger.Log($"Warning: GIF will be encoded at 50 FPS instead of {fpsOut.GetFloat()} as the format doesn't support frame rates that high.");
if (outMode == I.OutMode.VidGif && fpsOut > 50 && !(fpsLimit > 0 && fpsLimit <= 50))
Logger.Log($"Warning: GIF will be encoded at 50 FPS instead of {fpsOut} as the format doesn't support frame rates that high.");
if (!passes)
I.Cancel("Invalid settings detected.", true);