mirror of
https://github.com/n00mkrad/flowframes
synced 2024-11-16 19:10:31 +01:00
Show dedup stats for mpdecimate, better stats for magickdedupe, SBS fixes
This commit is contained in:
parent
cb3f42ca9c
commit
22b3ae2f18
@ -124,7 +124,7 @@ namespace Flowframes.Magick
|
||||
delStr = "Deleting";
|
||||
//File.Delete(frame2);
|
||||
framesToDelete.Add(frame2);
|
||||
if (debugLog) Logger.Log("[FrameDedup] Deleted " + Path.GetFileName(frame2));
|
||||
if (debugLog) Logger.Log("[Deduplication] Deleted " + Path.GetFileName(frame2));
|
||||
hasEncounteredAnyDupes = true;
|
||||
}
|
||||
statsFramesDeleted++;
|
||||
@ -142,7 +142,7 @@ namespace Flowframes.Magick
|
||||
if (sw.ElapsedMilliseconds >= 1000 || (i+1) == framePaths.Length) // Print every 1s (or when done)
|
||||
{
|
||||
sw.Restart();
|
||||
Logger.Log($"[FrameDedup] Difference from {Path.GetFileName(frame1)} to {Path.GetFileName(frame2)}: {diff.ToString("0.00")}% - {delStr}.", false, true);
|
||||
Logger.Log($"[Deduplication] Running de-duplication ({i}/{framePaths.Length}), deleted {statsFramesDeleted} duplicate frames so far...", false, true);
|
||||
Program.mainForm.SetProgress((int)Math.Round(((float)i / framePaths.Length) * 100f));
|
||||
if (imageCache.Count > bufferSize || (imageCache.Count > 50 && OSUtils.GetFreeRamMb() < 2500))
|
||||
ClearCache();
|
||||
@ -184,9 +184,9 @@ namespace Flowframes.Magick
|
||||
string keptPercent = $"{(100f - percentDeleted).ToString("0.0")}%";
|
||||
|
||||
if (skipped)
|
||||
Logger.Log($"[FrameDedup] First {skipAfterNoDupesFrames} frames did not have any duplicates - Skipping the rest!", false, true);
|
||||
Logger.Log($"[Deduplication] First {skipAfterNoDupesFrames} frames did not have any duplicates - Skipping the rest!", false, true);
|
||||
else
|
||||
Logger.Log($"[FrameDedup]{testStr} Done. Kept {framesLeft} ({keptPercent}) frames, deleted {framesDeleted} frames.", false, true);
|
||||
Logger.Log($"[Deduplication]{testStr} Done. Kept {framesLeft} ({keptPercent}) frames, deleted {framesDeleted} frames.", false, true);
|
||||
|
||||
if (statsFramesKept <= 0)
|
||||
Interpolate.Cancel("No frames were left after de-duplication!\n\nTry decreasing the de-duplication threshold.");
|
||||
|
@ -72,9 +72,8 @@ namespace Flowframes
|
||||
Program.mainForm.SetStatus("Done interpolating!");
|
||||
}
|
||||
|
||||
public static async Task ExtractFrames(string inPath, string outPath, bool extractAudio = true)
|
||||
public static async Task ExtractFrames(string inPath, string outPath, bool allowSceneDetect = true, bool extractAudio = true)
|
||||
{
|
||||
await Task.Delay(10);
|
||||
if (Config.GetBool("scnDetect"))
|
||||
{
|
||||
Program.mainForm.SetStatus("Extracting scenes from video...");
|
||||
@ -83,7 +82,18 @@ namespace Flowframes
|
||||
}
|
||||
|
||||
Program.mainForm.SetStatus("Extracting frames from video...");
|
||||
await FFmpegCommands.VideoToFrames(inPath, outPath, Config.GetInt("dedupMode") == 2, false, Utils.GetOutputResolution(inPath, true), false);
|
||||
bool mpdecimate = Config.GetInt("dedupMode") == 2;
|
||||
await FFmpegCommands.VideoToFrames(inPath, outPath, mpdecimate, false, Utils.GetOutputResolution(inPath, true), false);
|
||||
|
||||
if (mpdecimate)
|
||||
{
|
||||
int framesLeft = IOUtils.GetAmountOfFiles(outPath, false, $"*.png");
|
||||
int framesDeleted = currentInputFrameCount - framesLeft;
|
||||
float percentDeleted = ((float)framesDeleted / currentInputFrameCount) * 100f;
|
||||
string keptPercent = $"{(100f - percentDeleted).ToString("0.0")}%";
|
||||
Logger.Log($"[Deduplication] Kept {framesLeft} ({keptPercent}) frames, deleted {framesDeleted} frames.");
|
||||
}
|
||||
|
||||
Utils.FixConsecutiveSceneFrames(Path.Combine(current.tempFolder, Paths.scenesDir), current.framesFolder);
|
||||
|
||||
if (extractAudio)
|
||||
@ -100,7 +110,6 @@ namespace Flowframes
|
||||
string newFilename = Path.Combine(lastFrame.GetParentDir(), newNum.ToString().PadLeft(Padding.inputFrames, '0') + ".png");
|
||||
string firstFrame = new DirectoryInfo(outPath).GetFiles("*.png")[0].FullName;
|
||||
File.Copy(firstFrame, newFilename);
|
||||
Logger.Log("Copied loop frame.");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -82,26 +82,28 @@ namespace Flowframes.Main
|
||||
return;
|
||||
}
|
||||
|
||||
currentInputFrameCount = await InterpolateUtils.GetInputFrameCountAsync(current.inPath);
|
||||
AiProcess.filenameMap.Clear();
|
||||
bool extractAudio = true;
|
||||
Program.mainForm.SetStatus("Extracting frames from video...");
|
||||
await FFmpegCommands.VideoToFrames(current.inPath, current.framesFolder, Config.GetInt("dedupMode") == 2, false, InterpolateUtils.GetOutputResolution(current.inPath, true), false);
|
||||
|
||||
if (extractAudio)
|
||||
{
|
||||
string audioFile = Path.Combine(current.tempFolder, "audio.m4a");
|
||||
if (audioFile != null && !File.Exists(audioFile))
|
||||
await FFmpegCommands.ExtractAudio(current.inPath, audioFile);
|
||||
}
|
||||
if (!canceled && Config.GetBool("enableLoop") && Config.GetInt("timingMode") != 1)
|
||||
{
|
||||
string lastFrame = IOUtils.GetHighestFrameNumPath(current.framesFolder);
|
||||
int newNum = Path.GetFileName(lastFrame).GetInt() + 1;
|
||||
string newFilename = Path.Combine(lastFrame.GetParentDir(), newNum.ToString().PadLeft(Padding.inputFrames, '0') + ".png");
|
||||
string firstFrame = new DirectoryInfo(current.framesFolder).GetFiles("*.png")[0].FullName;
|
||||
File.Copy(firstFrame, newFilename);
|
||||
Logger.Log("Copied loop frame.");
|
||||
}
|
||||
ExtractFrames(current.inPath, current.framesFolder, false, true);
|
||||
|
||||
// Program.mainForm.SetStatus("Extracting frames from video...");
|
||||
// await FFmpegCommands.VideoToFrames(current.inPath, current.framesFolder, Config.GetInt("dedupMode") == 2, false, InterpolateUtils.GetOutputResolution(current.inPath, true), false);
|
||||
//
|
||||
// if (extractAudio)
|
||||
// {
|
||||
// string audioFile = Path.Combine(current.tempFolder, "audio.m4a");
|
||||
// if (audioFile != null && !File.Exists(audioFile))
|
||||
// await FFmpegCommands.ExtractAudio(current.inPath, audioFile);
|
||||
// }
|
||||
// if (!canceled && Config.GetBool("enableLoop") && Config.GetInt("timingMode") != 1)
|
||||
// {
|
||||
// string lastFrame = IOUtils.GetHighestFrameNumPath(current.framesFolder);
|
||||
// int newNum = Path.GetFileName(lastFrame).GetInt() + 1;
|
||||
// string newFilename = Path.Combine(lastFrame.GetParentDir(), newNum.ToString().PadLeft(Padding.inputFrames, '0') + ".png");
|
||||
// string firstFrame = new DirectoryInfo(current.framesFolder).GetFiles("*.png")[0].FullName;
|
||||
// File.Copy(firstFrame, newFilename);
|
||||
// }
|
||||
}
|
||||
|
||||
public static async Task DoInterpolate()
|
||||
|
Loading…
Reference in New Issue
Block a user