mirror of
https://github.com/n00mkrad/flowframes.git
synced 2025-12-24 20:29:26 +01:00
AutoEnc: Actually delete old frames instead of overwriting with dummy data
This commit is contained in:
@@ -467,9 +467,10 @@ namespace Flowframes.IO
|
||||
}
|
||||
}
|
||||
|
||||
public static bool DeleteIfExists (string path) // Returns true if the file/dir exists
|
||||
public static bool DeleteIfExists (string path, bool log = false) // Returns true if the file/dir exists
|
||||
{
|
||||
Logger.Log($"DeleteIfExists({path})", true);
|
||||
if(log)
|
||||
Logger.Log($"DeleteIfExists({path})", true);
|
||||
|
||||
if (!IsPathDirectory(path) && File.Exists(path))
|
||||
{
|
||||
|
||||
@@ -177,7 +177,9 @@ namespace Flowframes.Main
|
||||
if (!FrameIsStillNeeded(interpFramesLines[frame], frame)) // Make sure frames are no longer needed (for dupes) before deleting!
|
||||
{
|
||||
string framePath = Path.Combine(interpFramesPath, interpFramesLines[frame]);
|
||||
IOUtils.OverwriteFileWithText(framePath); // Overwrite to save space without breaking progress counter
|
||||
//IOUtils.OverwriteFileWithText(framePath); // Overwrite to save space without breaking progress counter
|
||||
IOUtils.TryDeleteIfExists(framePath);
|
||||
InterpolationProgress.deletedFramesCount++;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -15,7 +15,6 @@ using System.IO;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
using Win32Interop.Structs;
|
||||
using Padding = Flowframes.Data.Padding;
|
||||
using Utils = Flowframes.Main.InterpolateUtils;
|
||||
|
||||
|
||||
@@ -67,8 +67,9 @@ namespace Flowframes
|
||||
if (Interpolate.canceled) return;
|
||||
Program.mainForm.SetProgress(100);
|
||||
AiProcessSuspend.SetRunning(false);
|
||||
int interpolatedFrames = IOUtils.GetAmountOfFiles(Interpolate.current.interpFolder, false, "*" + Interpolate.current.interpExt);
|
||||
InterpolationProgress.UpdateInterpProgress(interpolatedFrames, InterpolationProgress.targetFrames);
|
||||
int interpFramesFiles = IOUtils.GetAmountOfFiles(Interpolate.current.interpFolder, false, "*" + Interpolate.current.interpExt);
|
||||
int interpFramesCount = interpFramesFiles + InterpolationProgress.deletedFramesCount;
|
||||
InterpolationProgress.UpdateInterpProgress(interpFramesCount, InterpolationProgress.targetFrames);
|
||||
string logStr = $"Done running {aiName} - Interpolation took {FormatUtils.Time(processTime.Elapsed)}. Peak Output FPS: {InterpolationProgress.peakFpsOut.ToString("0.00")}";
|
||||
|
||||
if (Interpolate.currentlyUsingAutoEnc && AutoEncode.HasWorkToDo())
|
||||
@@ -80,9 +81,9 @@ namespace Flowframes
|
||||
Logger.Log(logStr);
|
||||
processTime.Stop();
|
||||
|
||||
if(interpolatedFrames < 3)
|
||||
if(interpFramesCount < 3)
|
||||
{
|
||||
string amount = interpolatedFrames > 0 ? $"Only {interpolatedFrames}" : "No";
|
||||
string amount = interpFramesCount > 0 ? $"Only {interpFramesCount}" : "No";
|
||||
Interpolate.Cancel($"Interpolation failed - {amount} interpolated frames were created.");
|
||||
return;
|
||||
}
|
||||
@@ -448,7 +449,7 @@ namespace Flowframes
|
||||
{
|
||||
hasShownError = true;
|
||||
bool usingDain = (Interpolate.current.ai.aiName == Networks.dainNcnn.aiName);
|
||||
string msg = usingDain ? "\n\nTry reducing the tile size in the AI settings." : "Try a lower resolution (Settings -> Max Video Size).";
|
||||
string msg = usingDain ? "\n\nTry reducing the tile size in the AI settings." : "\n\nTry a lower resolution (Settings -> Max Video Size).";
|
||||
InterpolateUtils.ShowMessage($"Vulkan ran out of memory!\n\n{line}{msg}", "Error");
|
||||
}
|
||||
|
||||
|
||||
@@ -16,6 +16,7 @@ namespace Flowframes.UI
|
||||
{
|
||||
class InterpolationProgress
|
||||
{
|
||||
public static int deletedFramesCount;
|
||||
public static int lastFrame;
|
||||
public static int targetFrames;
|
||||
public static string currentOutdir;
|
||||
@@ -34,6 +35,7 @@ namespace Flowframes.UI
|
||||
Logger.Log($"Starting GetProgressByFrameAmount() loop for outdir '{currentOutdir}', target is {target} frames", true);
|
||||
bool firstProgUpd = true;
|
||||
Program.mainForm.SetProgress(0);
|
||||
deletedFramesCount = 0;
|
||||
lastFrame = 0;
|
||||
peakFpsOut = 0f;
|
||||
|
||||
@@ -141,8 +143,10 @@ namespace Flowframes.UI
|
||||
{
|
||||
while (Program.busy && (i + 10) > interpolatedInputFramesCount) await Task.Delay(1000);
|
||||
if (!Program.busy) break;
|
||||
|
||||
if (i != 0 && i != inputFrames.Length - 1)
|
||||
IOUtils.OverwriteFileWithText(inputFrames[i]);
|
||||
|
||||
if (i % 10 == 0) await Task.Delay(10);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user