mirror of
https://github.com/n00mkrad/flowframes.git
synced 2026-07-13 14:00:48 +02:00
Fixed ReverseRenaming being ultra slow + only run if SBS mode
This commit is contained in:
@@ -15,6 +15,7 @@ namespace Flowframes
|
||||
class AvProcess
|
||||
{
|
||||
public static Process lastProcess;
|
||||
public static Stopwatch timeSinceLastOutput = new Stopwatch();
|
||||
public enum TaskType { ExtractFrames, Encode, GetInfo, Merge, Other };
|
||||
public static TaskType lastTask = TaskType.Other;
|
||||
|
||||
@@ -36,6 +37,7 @@ namespace Flowframes
|
||||
currentLogMode = logMode;
|
||||
showProgressBar = progressBar;
|
||||
Process ffmpeg = OSUtils.NewProcess(true);
|
||||
timeSinceLastOutput.Restart();
|
||||
lastProcess = ffmpeg;
|
||||
lastTask = taskType;
|
||||
if(!string.IsNullOrWhiteSpace(workingDir))
|
||||
@@ -55,6 +57,7 @@ namespace Flowframes
|
||||
|
||||
static void FfmpegOutputHandler(object sendingProcess, DataReceivedEventArgs outLine)
|
||||
{
|
||||
timeSinceLastOutput.Restart();
|
||||
if (outLine == null || outLine.Data == null)
|
||||
return;
|
||||
string line = outLine.Data;
|
||||
|
||||
@@ -32,6 +32,7 @@ namespace Flowframes
|
||||
public Size scaledResolution;
|
||||
|
||||
public bool alpha;
|
||||
public bool stepByStep;
|
||||
|
||||
public InterpSettings(string inPathArg, string outPathArg, AI aiArg, float inFpsArg, int interpFactorArg, Interpolate.OutMode outModeArg, string modelArg)
|
||||
{
|
||||
@@ -45,6 +46,7 @@ namespace Flowframes
|
||||
model = modelArg;
|
||||
|
||||
alpha = false;
|
||||
stepByStep = false;
|
||||
|
||||
try
|
||||
{
|
||||
|
||||
@@ -287,9 +287,12 @@ namespace Flowframes.IO
|
||||
foreach (KeyValuePair<string, string> pair in oldNewMap)
|
||||
{
|
||||
TryMove(pair.Value, pair.Key);
|
||||
counter++;
|
||||
|
||||
if (counter % 1000 == 0)
|
||||
await Task.Delay(1);
|
||||
}
|
||||
|
||||
if (clearDict)
|
||||
oldNewMap.Clear();
|
||||
}
|
||||
|
||||
@@ -77,7 +77,6 @@ namespace Flowframes.Main
|
||||
|
||||
if (unencodedFrameLines.Count > 0 && (unencodedFrameLines.Count >= (chunkSize + safetyBufferFrames) || !aiRunning)) // Encode every n frames, or after process has exited
|
||||
{
|
||||
|
||||
List<int> frameLinesToEncode = aiRunning ? unencodedFrameLines.Take(chunkSize).ToList() : unencodedFrameLines; // Take all remaining frames if process is done
|
||||
|
||||
string lastOfChunk = Path.Combine(interpFramesPath, interpFramesLines[frameLinesToEncode.Last()]);
|
||||
@@ -99,7 +98,7 @@ namespace Flowframes.Main
|
||||
|
||||
if (Interpolate.canceled) return;
|
||||
|
||||
if (Config.GetInt("autoEncMode") == 2)
|
||||
if (aiRunning && Config.GetInt("autoEncMode") == 2)
|
||||
Task.Run(() => DeleteOldFramesAsync(interpFramesPath, frameLinesToEncode));
|
||||
|
||||
if (Interpolate.canceled) return;
|
||||
@@ -117,7 +116,9 @@ namespace Flowframes.Main
|
||||
|
||||
if (Interpolate.canceled) return;
|
||||
|
||||
await IOUtils.ReverseRenaming(AiProcess.filenameMap, true); // Get timestamps back
|
||||
if(!Interpolate.current.stepByStep)
|
||||
await IOUtils.ReverseRenaming(AiProcess.filenameMap, true); // Get timestamps back
|
||||
|
||||
await CreateVideo.ChunksToVideos(Interpolate.current.tempFolder, videoChunksFolder, Interpolate.current.outFilename);
|
||||
}
|
||||
catch (Exception e)
|
||||
@@ -142,7 +143,7 @@ namespace Flowframes.Main
|
||||
File.WriteAllText(framePath, "THIS IS A DUMMY FILE - DO NOT DELETE ME"); // Overwrite to save space without breaking progress counter
|
||||
}
|
||||
|
||||
if(counter % 100 == 0)
|
||||
if(counter % 1000 == 0)
|
||||
await Task.Delay(1);
|
||||
|
||||
counter++;
|
||||
|
||||
@@ -147,6 +147,7 @@ namespace Flowframes.Main
|
||||
public static async Task<int> GetInputFrameCountAsync (string path)
|
||||
{
|
||||
string hash = await IOUtils.GetHashAsync(path, IOUtils.Hash.xxHash); // Get checksum for caching
|
||||
|
||||
if (hash.Length > 1 && frameCountCache.ContainsKey(hash))
|
||||
{
|
||||
Logger.Log($"FrameCountCache contains this hash ({hash}), using cached frame count.", true);
|
||||
@@ -168,6 +169,7 @@ namespace Flowframes.Main
|
||||
Logger.Log($"Adding hash ({hash}) with frame count {frameCount} to cache.", true);
|
||||
frameCountCache[hash] = frameCount; // Use CRC32 instead of path to avoid using cached value if file was changed
|
||||
}
|
||||
|
||||
return frameCount;
|
||||
}
|
||||
|
||||
|
||||
@@ -25,11 +25,8 @@ namespace Flowframes.Main
|
||||
|
||||
public static void Save ()
|
||||
{
|
||||
Logger.Log("Save()", true);
|
||||
if (timeSinceLastSave.IsRunning && timeSinceLastSave.ElapsedMilliseconds < (timeBetweenSaves * 1000f).RoundToInt()) return;
|
||||
Logger.Log("Stopwatch is running and elapsed time is long enough to save again", true);
|
||||
int frames = (int)Math.Round((float)currentOutFrames / Interpolate.current.interpFactor) - safetyDelayFrames;
|
||||
Logger.Log($"frames minus safetyDelayFrames = {frames}", true);
|
||||
if (frames < 1) return;
|
||||
timeSinceLastSave.Restart();
|
||||
Directory.CreateDirectory(Path.Combine(Interpolate.current.tempFolder, Paths.resumeDir));
|
||||
|
||||
@@ -62,18 +62,15 @@ namespace Flowframes
|
||||
Logger.Log(logStr);
|
||||
processTime.Stop();
|
||||
|
||||
Stopwatch timeSinceFfmpegRan = new Stopwatch();
|
||||
timeSinceFfmpegRan.Restart();
|
||||
|
||||
while (Interpolate.currentlyUsingAutoEnc && Program.busy)
|
||||
{
|
||||
if (AvProcess.lastProcess != null && !AvProcess.lastProcess.HasExited && AvProcess.lastTask == AvProcess.TaskType.Encode)
|
||||
{
|
||||
timeSinceFfmpegRan.Restart();
|
||||
string lastLine = AvProcess.lastOutputFfmpeg.SplitIntoLines().Last();
|
||||
Logger.Log(lastLine.Trim().TrimWhitespaces(), false, Logger.GetLastLine().Contains("frame"));
|
||||
}
|
||||
if (timeSinceFfmpegRan.ElapsedMilliseconds > 3000)
|
||||
|
||||
if (AvProcess.timeSinceLastOutput.IsRunning && AvProcess.timeSinceLastOutput.ElapsedMilliseconds > 2500)
|
||||
break;
|
||||
|
||||
await Task.Delay(500);
|
||||
|
||||
Reference in New Issue
Block a user