mirror of
https://github.com/n00mkrad/flowframes.git
synced 2025-12-25 04:39:25 +01:00
Only loop output if loop is on, fix SBS frame extraction not clearing, more
Improved Interpolate.Cleanup() with retries minOutVidLength now defaults to 5s instead of 0s Frames filenameMap now uses zeropadding value from Padding class
This commit is contained in:
@@ -110,10 +110,7 @@ namespace Flowframes.Main
|
||||
{
|
||||
await FFmpegCommands.FramesToVideoConcat(vfrFile, outPath, mode, fps, resampleFps);
|
||||
await MergeAudio(i.current.inPath, outPath);
|
||||
|
||||
int looptimes = GetLoopTimes();
|
||||
if (looptimes > 0)
|
||||
await Loop(currentOutFile, looptimes);
|
||||
await Loop(currentOutFile, GetLoopTimes());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -154,10 +151,7 @@ namespace Flowframes.Main
|
||||
{
|
||||
await FFmpegCommands.ConcatVideos(vfrFile, outPath, -1);
|
||||
await MergeAudio(i.current.inPath, outPath);
|
||||
|
||||
int looptimes = GetLoopTimes();
|
||||
if (looptimes > 0)
|
||||
await Loop(outPath, looptimes);
|
||||
await Loop(outPath, GetLoopTimes());
|
||||
}
|
||||
|
||||
public static async Task EncodeChunk(string outPath, i.OutMode mode, int firstFrameNum, int framesAmount)
|
||||
@@ -185,6 +179,7 @@ namespace Flowframes.Main
|
||||
|
||||
static async Task Loop(string outPath, int looptimes)
|
||||
{
|
||||
if (looptimes < 1 || !Config.GetBool("enableLoop")) return;
|
||||
Logger.Log($"Looping {looptimes} {(looptimes == 1 ? "time" : "times")} to reach target length of {Config.GetInt("minOutVidLength")}s...");
|
||||
await FFmpegCommands.LoopVideo(outPath, looptimes, Config.GetInt("loopMode") == 0);
|
||||
}
|
||||
|
||||
@@ -34,6 +34,7 @@ namespace Flowframes
|
||||
|
||||
public static async Task Start()
|
||||
{
|
||||
if (Program.busy) return;
|
||||
canceled = false;
|
||||
if (!Utils.InputIsValid(current.inPath, current.outPath, current.outFps, current.interpFactor, current.outMode)) return; // General input checks
|
||||
if (!Utils.CheckAiAvailable(current.ai)) return; // Check if selected AI pkg is installed
|
||||
@@ -54,7 +55,7 @@ namespace Flowframes
|
||||
if(!currentlyUsingAutoEnc)
|
||||
await CreateVideo.Export(current.interpFolder, current.outFilename, current.outMode);
|
||||
IOUtils.ReverseRenaming(AiProcess.filenameMap, true); // Get timestamps back
|
||||
Cleanup(current.interpFolder);
|
||||
await Cleanup();
|
||||
Program.mainForm.SetWorking(false);
|
||||
Logger.Log("Total processing time: " + FormatUtils.Time(sw.Elapsed));
|
||||
sw.Stop();
|
||||
@@ -143,7 +144,17 @@ namespace Flowframes
|
||||
|
||||
if (canceled) return;
|
||||
|
||||
AiProcess.filenameMap = IOUtils.RenameCounterDirReversible(current.framesFolder, "png", 1, 8);
|
||||
try
|
||||
{
|
||||
AiProcess.filenameMap = IOUtils.RenameCounterDirReversible(current.framesFolder, "png", 1, Padding.inputFramesRenamed);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Logger.Log($"Error renaming frame files: {e.Message}");
|
||||
Cancel("Error renaming frame files. Check the log for details.");
|
||||
}
|
||||
|
||||
if (canceled) return;
|
||||
}
|
||||
|
||||
public static async Task RunAi(string outpath, AI ai, bool stepByStep = false)
|
||||
@@ -197,19 +208,23 @@ namespace Flowframes
|
||||
Utils.ShowMessage($"Canceled:\n\n{reason}");
|
||||
}
|
||||
|
||||
public static void Cleanup(string interpFramesDir, bool ignoreKeepSetting = false)
|
||||
public static async Task Cleanup(bool ignoreKeepSetting = false, int retriesLeft = 3, bool isRetry = false)
|
||||
{
|
||||
if (!ignoreKeepSetting && Config.GetBool("keepTempFolder")) return;
|
||||
Logger.Log("Deleting temporary files...");
|
||||
if ((!ignoreKeepSetting && Config.GetBool("keepTempFolder")) || !Program.busy) return;
|
||||
if (!isRetry)
|
||||
Logger.Log("Deleting temporary files...");
|
||||
try
|
||||
{
|
||||
if (Config.GetBool("keepFrames"))
|
||||
IOUtils.Copy(interpFramesDir, Path.Combine(current.tempFolder.GetParentDir(), Path.GetFileName(current.tempFolder).Replace("-temp", "-interpframes")));
|
||||
Directory.Delete(current.tempFolder, true);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Logger.Log("Cleanup Error: " + e.Message, true);
|
||||
if(retriesLeft > 0)
|
||||
{
|
||||
await Task.Delay(1000);
|
||||
await Cleanup(ignoreKeepSetting, retriesLeft - 1, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,12 +17,6 @@ namespace Flowframes.Main
|
||||
{
|
||||
public enum Step { ExtractScnChanges, ExtractFrames, Interpolate, CreateVid, Reset }
|
||||
|
||||
//public static string current.inPath;
|
||||
//public static string currentOutPath;
|
||||
//public static string current.interpFolder;
|
||||
//public static AI currentAi;
|
||||
//public static OutMode currentOutMode;
|
||||
|
||||
public static async Task Run(string step)
|
||||
{
|
||||
Logger.Log($"[SBS] Running step '{step}'", true);
|
||||
@@ -42,7 +36,7 @@ namespace Flowframes.Main
|
||||
|
||||
if (step.Contains("Extract Frames"))
|
||||
{
|
||||
await GetFrames();
|
||||
await ExtractFramesStep();
|
||||
}
|
||||
|
||||
if (step.Contains("Run Interpolation"))
|
||||
@@ -71,7 +65,7 @@ namespace Flowframes.Main
|
||||
await Task.Delay(10);
|
||||
}
|
||||
|
||||
public static async Task ExtractVideoFrames()
|
||||
public static async Task ExtractFramesStep()
|
||||
{
|
||||
if (!IOUtils.TryDeleteIfExists(current.framesFolder))
|
||||
{
|
||||
@@ -82,7 +76,7 @@ namespace Flowframes.Main
|
||||
currentInputFrameCount = await InterpolateUtils.GetInputFrameCountAsync(current.inPath);
|
||||
AiProcess.filenameMap.Clear();
|
||||
|
||||
await ExtractFrames(current.inPath, current.framesFolder, false, true);
|
||||
await GetFrames();
|
||||
}
|
||||
|
||||
public static async Task DoInterpolate()
|
||||
@@ -136,7 +130,7 @@ namespace Flowframes.Main
|
||||
|
||||
public static async Task Reset()
|
||||
{
|
||||
Cleanup(current.interpFolder, true);
|
||||
await Cleanup(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user