Cleanup, fixed dupe dict not working with new code

This commit is contained in:
N00MKRAD
2021-04-04 12:46:41 +02:00
parent 0dc9e0ba3c
commit 943c87845f
4 changed files with 8 additions and 35 deletions

View File

@@ -36,14 +36,6 @@ namespace Flowframes.Magick
if (setStatus)
Program.mainForm.SetStatus("Blending scene transitions...");
// bool renameFramesFirst = !FrameRename.framesAreRenamed;
//
// if (renameFramesFirst)
// {
// Dictionary<string, string> renamedFilesDict = await IOUtils.RenameCounterDirReversibleAsync(Interpolate.current.framesFolder, "png", 1, Padding.inputFramesRenamed);
// AiProcess.SetFilenameMap(renamedFilesDict.ToDictionary(x => Path.GetFileName(x.Key), x => Path.GetFileName(x.Value)), true);
// }
int amountOfBlendFrames = (int)Interpolate.current.interpFactor - 1;
List<Task> runningTasks = new List<Task>();
@@ -109,12 +101,6 @@ namespace Flowframes.Magick
Logger.Log($"Created {totalFrames} blend frames in {FormatUtils.TimeSw(sw)} ({(totalFrames / (sw.ElapsedMilliseconds / 1000f)).ToString("0.00")} FPS)", true);
// if (renameFramesFirst)
// {
// await IOUtils.ReverseRenaming(Interpolate.current.framesFolder, FrameRename.filenameMap); // Get timestamps back
// AiProcess.SetFilenameMap(null, false);
// }
if (setStatus)
Program.mainForm.SetStatus(oldStatus);
}

View File

@@ -123,9 +123,10 @@ namespace Flowframes.Main
if (Interpolate.canceled) return;
if (i >= frameFilesWithoutLast.Length) break;
string inputFilenameNoExt = Path.GetFileNameWithoutExtension(frameFilesWithoutLast[i].Name);
int dupesAmount = dupesDict.ContainsKey(inputFilenameNoExt) ? dupesDict[inputFilenameNoExt] : 0;
bool discardThisFrame = (sceneDetection && i < frameFilesWithoutLast.Length && sceneFrames.Contains(Path.GetFileNameWithoutExtension(FrameRename.importFilenames[i + 1]))); // i+2 is in scene detection folder, means i+1 is ugly interp frame
string frameName = Path.GetFileNameWithoutExtension(frameFilesWithoutLast[i].Name);
string frameNameImport = Path.GetFileNameWithoutExtension(FrameRename.importFilenames[i]);
int dupesAmount = dupesDict.ContainsKey(frameNameImport) ? dupesDict[frameNameImport] : 0;
bool discardThisFrame = (sceneDetection && i < frameFilesWithoutLast.Length && sceneFrames.Contains(frameNameImport)); // i+2 is in scene detection folder, means i+1 is ugly interp frame
for (int frm = 0; frm < interpFramesAmount; frm++) // Generate frames file lines
{
@@ -136,7 +137,7 @@ namespace Flowframes.Main
string scnChangeNote = $"SCN:{frameBeforeScn}>{frameAfterScn}";
totalFileCount++;
fileContent = WriteFrameWithDupes(dupesAmount, fileContent, totalFileCount, ext, debug, $"[In: {inputFilenameNoExt}] [{((frm == 0) ? " Source " : $"Interp {frm}")}]", scnChangeNote);
fileContent = WriteFrameWithDupes(dupesAmount, fileContent, totalFileCount, ext, debug, $"[In: {frameName}] [{((frm == 0) ? " Source " : $"Interp {frm}")}]", scnChangeNote);
if (Config.GetInt("sceneChangeFillMode") == 0) // Duplicate last frame
{
@@ -145,7 +146,7 @@ namespace Flowframes.Main
for (int dupeCount = 1; dupeCount < interpFramesAmount; dupeCount++)
{
totalFileCount++;
fileContent = WriteFrameWithDupes(dupesAmount, fileContent, lastNum, ext, debug, $"[In: {inputFilenameNoExt}] [DISCARDED]");
fileContent = WriteFrameWithDupes(dupesAmount, fileContent, lastNum, ext, debug, $"[In: {frameName}] [DISCARDED]");
}
}
else
@@ -153,7 +154,7 @@ namespace Flowframes.Main
for (int dupeCount = 1; dupeCount < interpFramesAmount; dupeCount++)
{
totalFileCount++;
fileContent = WriteFrameWithDupes(dupesAmount, fileContent, totalFileCount, ext, debug, $"[In: {inputFilenameNoExt}] [BLEND FRAME]");
fileContent = WriteFrameWithDupes(dupesAmount, fileContent, totalFileCount, ext, debug, $"[In: {frameName}] [BLEND FRAME]");
}
}
@@ -162,7 +163,7 @@ namespace Flowframes.Main
else
{
totalFileCount++;
fileContent = WriteFrameWithDupes(dupesAmount, fileContent, totalFileCount, ext, debug, $"[In: {inputFilenameNoExt}] [{((frm == 0) ? " Source " : $"Interp {frm}")}]");
fileContent = WriteFrameWithDupes(dupesAmount, fileContent, totalFileCount, ext, debug, $"[In: {frameName}] [{((frm == 0) ? " Source " : $"Interp {frm}")}]");
}
}
}

View File

@@ -14,20 +14,11 @@ namespace Flowframes.MiscUtils
{
public static bool framesAreRenamed;
public static string[] importFilenames; // index=renamed, value=original TODO: Store on disk instead for crashes?
public static Dictionary<string, string> originalFilenamesReversed;
public static async Task Rename()
{
importFilenames = IOUtils.GetFilesSorted(Interpolate.current.framesFolder).Select(x => Path.GetFileName(x)).ToArray();
//originalFilenamesReversed = new string[originalFilenames.Length];
await IOUtils.RenameCounterDir(Interpolate.current.framesFolder, 0, Padding.inputFramesRenamed);
//for(int i = 0; i < originalFilenames.Length; i++)
//{
// int idx = originalFilenames[i].GetInt();
// originalFilenamesReversed[idx] = originalFilenames[i];
//}
framesAreRenamed = true;
}

View File

@@ -211,11 +211,6 @@ namespace Flowframes
{
string outPath = Path.Combine(inPath.GetParentDir(), outDir);
Directory.CreateDirectory(outPath);
//string uhdStr = await InterpolateUtils.UseUHD() ? "--UHD" : "";
//string wthreads = $"--wthreads {2 * (int)interpFactor}";
//string rbuffer = $"--rbuffer {Config.GetInt("flavrCudaBufferSize", 200)}";
//string scale = $"--scale {Config.GetFloat("flavrCudaScale", 1.0f).ToStringDot()}";
// string prec = Config.GetBool("flavrCudaFp16") ? "--fp16" : "";
string args = $" --input {inPath.Wrap()} --output {outPath.Wrap()} --model {mdl}/{mdl}.pth --factor {interpFactor}";
Process flavrPy = OSUtils.NewProcess(!OSUtils.ShowHiddenCmd());