mirror of
https://github.com/n00mkrad/flowframes.git
synced 2025-12-21 10:49:25 +01:00
Fixed dupes dict bug, fixed autoenc getting stuck (i think?)
This commit is contained in:
@@ -77,7 +77,7 @@ namespace Flowframes.Magick
|
|||||||
|
|
||||||
bool hasReachedEnd = false;
|
bool hasReachedEnd = false;
|
||||||
|
|
||||||
string infoFile = Path.Combine(path.GetParentDir(), $"dupes.ini");
|
string infoFile = Path.Combine(path.GetParentDir(), $"dupes-magick.ini");
|
||||||
string fileContent = "";
|
string fileContent = "";
|
||||||
|
|
||||||
for (int i = 0; i < framePaths.Length; i++) // Loop through frames
|
for (int i = 0; i < framePaths.Length; i++) // Loop through frames
|
||||||
@@ -169,7 +169,7 @@ namespace Flowframes.Magick
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
File.WriteAllText(infoFile, fileContent);
|
// File.WriteAllText(infoFile, fileContent); // DISABLED FOR NOW as we use a single piece of code for mpdec and this code
|
||||||
|
|
||||||
foreach (string frame in framesToDelete)
|
foreach (string frame in framesToDelete)
|
||||||
IOUtils.TryDeleteIfExists(frame);
|
IOUtils.TryDeleteIfExists(frame);
|
||||||
|
|||||||
@@ -59,7 +59,7 @@ namespace Flowframes.Main
|
|||||||
|
|
||||||
//unencodedFrameLines = interpFramesLines.Select(x => x.GetInt()).ToList().Except(encodedFrameLines).ToList();
|
//unencodedFrameLines = interpFramesLines.Select(x => x.GetInt()).ToList().Except(encodedFrameLines).ToList();
|
||||||
|
|
||||||
Logger.Log($"{unencodedFrameLines.Count} unencoded frame lines, {encodedFrameLines.Count} encoded frame lines", true, false, "ffmpeg");
|
//Logger.Log($"{unencodedFrameLines.Count} unencoded frame lines, {encodedFrameLines.Count} encoded frame lines", true, false, "ffmpeg");
|
||||||
|
|
||||||
unencodedFrameLines.Clear();
|
unencodedFrameLines.Clear();
|
||||||
for(int vfrLine = 0; vfrLine < interpFramesLines.Length; vfrLine++)
|
for(int vfrLine = 0; vfrLine < interpFramesLines.Length; vfrLine++)
|
||||||
@@ -77,14 +77,14 @@ namespace Flowframes.Main
|
|||||||
busy = true;
|
busy = true;
|
||||||
|
|
||||||
List<int> frameLinesToEncode = aiRunning ? unencodedFrameLines.Take(chunkSize).ToList() : unencodedFrameLines; // Take all remaining frames if process is done
|
List<int> frameLinesToEncode = aiRunning ? unencodedFrameLines.Take(chunkSize).ToList() : unencodedFrameLines; // Take all remaining frames if process is done
|
||||||
Logger.Log($"{unencodedFrameLines.Count} unencoded frame lines, {IOUtils.GetAmountOfFiles(interpFramesFolder, false)} frames in interp folder", true, false, "ffmpeg");
|
//Logger.Log($"{unencodedFrameLines.Count} unencoded frame lines, {IOUtils.GetAmountOfFiles(interpFramesFolder, false)} frames in interp folder", true, false, "ffmpeg");
|
||||||
Logger.Log($"Encoding Chunk #{videoIndex} using {Path.GetFileName(interpFramesLines[frameLinesToEncode.First()])} through {Path.GetFileName(Path.GetFileName(interpFramesLines[frameLinesToEncode.Last()]))}", true, false, "ffmpeg");
|
Logger.Log($"Encoding Chunk #{videoIndex} using {Path.GetFileName(interpFramesLines[frameLinesToEncode.First()])} through {Path.GetFileName(Path.GetFileName(interpFramesLines[frameLinesToEncode.Last()]))}", true, false, "ffmpeg");
|
||||||
|
|
||||||
//IOUtils.ZeroPadDir(framesToEncode, Padding.interpFrames); // Zero-pad frames before encoding to make sure filenames match with VFR file
|
//IOUtils.ZeroPadDir(framesToEncode, Padding.interpFrames); // Zero-pad frames before encoding to make sure filenames match with VFR file
|
||||||
|
|
||||||
string outpath = Path.Combine(videoChunksFolder, $"{videoIndex.ToString().PadLeft(4, '0')}{FFmpegUtils.GetExt(Interpolate.current.outMode)}");
|
string outpath = Path.Combine(videoChunksFolder, $"{videoIndex.ToString().PadLeft(4, '0')}{FFmpegUtils.GetExt(Interpolate.current.outMode)}");
|
||||||
int firstFrameNum = frameLinesToEncode[0];
|
int firstFrameNum = frameLinesToEncode[0];
|
||||||
await CreateVideo.EncodeChunk(outpath, Interpolate.current.outMode, firstFrameNum - 1, frameLinesToEncode.Count);
|
await CreateVideo.EncodeChunk(outpath, Interpolate.current.outMode, firstFrameNum, frameLinesToEncode.Count);
|
||||||
|
|
||||||
if(Interpolate.canceled) return;
|
if(Interpolate.canceled) return;
|
||||||
|
|
||||||
@@ -101,6 +101,7 @@ namespace Flowframes.Main
|
|||||||
}
|
}
|
||||||
|
|
||||||
encodedFrameLines.AddRange(frameLinesToEncode);
|
encodedFrameLines.AddRange(frameLinesToEncode);
|
||||||
|
//Logger.Log($"Adding {frameLinesToEncode.Count} frameLinesToEncode to encodedFrameLines, new count is {encodedFrameLines.Count}");
|
||||||
|
|
||||||
Logger.Log("Done Encoding Chunk #" + videoIndex, true, false, "ffmpeg");
|
Logger.Log("Done Encoding Chunk #" + videoIndex, true, false, "ffmpeg");
|
||||||
videoIndex++;
|
videoIndex++;
|
||||||
@@ -125,6 +126,7 @@ namespace Flowframes.Main
|
|||||||
public static bool HasWorkToDo ()
|
public static bool HasWorkToDo ()
|
||||||
{
|
{
|
||||||
if (Interpolate.canceled || interpFramesFolder == null) return false;
|
if (Interpolate.canceled || interpFramesFolder == null) return false;
|
||||||
|
//Logger.Log($"HasWorkToDo - Process Running: {(AiProcess.currentAiProcess != null && !AiProcess.currentAiProcess.HasExited)} - encodedFrameLines.Count: {encodedFrameLines.Count} - interpFramesLines.Length: {interpFramesLines.Length}");
|
||||||
return ((AiProcess.currentAiProcess != null && !AiProcess.currentAiProcess.HasExited) || encodedFrameLines.Count < interpFramesLines.Length);
|
return ((AiProcess.currentAiProcess != null && !AiProcess.currentAiProcess.HasExited) || encodedFrameLines.Count < interpFramesLines.Length);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -154,8 +154,8 @@ namespace Flowframes.Main
|
|||||||
|
|
||||||
static void LoadDupesFile (string path)
|
static void LoadDupesFile (string path)
|
||||||
{
|
{
|
||||||
if (!File.Exists(path)) return;
|
|
||||||
dupesDict.Clear();
|
dupesDict.Clear();
|
||||||
|
if (!File.Exists(path)) return;
|
||||||
string[] dupesFileLines = IOUtils.ReadLines(path);
|
string[] dupesFileLines = IOUtils.ReadLines(path);
|
||||||
foreach(string line in dupesFileLines)
|
foreach(string line in dupesFileLines)
|
||||||
{
|
{
|
||||||
@@ -186,6 +186,8 @@ namespace Flowframes.Main
|
|||||||
if (Directory.Exists(scnFramesPath))
|
if (Directory.Exists(scnFramesPath))
|
||||||
sceneFrames = Directory.GetFiles(scnFramesPath).Select(file => Path.GetFileNameWithoutExtension(file)).ToList();
|
sceneFrames = Directory.GetFiles(scnFramesPath).Select(file => Path.GetFileNameWithoutExtension(file)).ToList();
|
||||||
|
|
||||||
|
bool debug = false;
|
||||||
|
|
||||||
int totalFileCount = 1;
|
int totalFileCount = 1;
|
||||||
for (int i = 0; i < (frameFiles.Length - 1); i++)
|
for (int i = 0; i < (frameFiles.Length - 1); i++)
|
||||||
{
|
{
|
||||||
@@ -194,7 +196,8 @@ namespace Flowframes.Main
|
|||||||
int interpFramesAmount = interpFactor;
|
int interpFramesAmount = interpFactor;
|
||||||
string inputFilenameNoExt = Path.GetFileNameWithoutExtension(frameFiles[i].Name);
|
string inputFilenameNoExt = Path.GetFileNameWithoutExtension(frameFiles[i].Name);
|
||||||
int dupesAmount = dupesDict.ContainsKey(inputFilenameNoExt) ? dupesDict[inputFilenameNoExt] : 0;
|
int dupesAmount = dupesDict.ContainsKey(inputFilenameNoExt) ? dupesDict[inputFilenameNoExt] : 0;
|
||||||
//Logger.Log($"{Path.GetFileNameWithoutExtension(frameFiles[i].Name)} has {dupesAmount} dupes", true);
|
|
||||||
|
if(debug) Logger.Log($"{Path.GetFileNameWithoutExtension(frameFiles[i].Name)} has {dupesAmount} dupes", true);
|
||||||
|
|
||||||
bool discardThisFrame = (sceneDetection && (i + 2) < frameFiles.Length && sceneFrames.Contains(Path.GetFileNameWithoutExtension(frameFiles[i + 1].Name))); // i+2 is in scene detection folder, means i+1 is ugly interp frame
|
bool discardThisFrame = (sceneDetection && (i + 2) < frameFiles.Length && sceneFrames.Contains(Path.GetFileNameWithoutExtension(frameFiles[i + 1].Name))); // i+2 is in scene detection folder, means i+1 is ugly interp frame
|
||||||
|
|
||||||
@@ -203,25 +206,24 @@ namespace Flowframes.Main
|
|||||||
if (loopEnabled && i == (frameFiles.Length - 2))
|
if (loopEnabled && i == (frameFiles.Length - 2))
|
||||||
interpFramesAmount = interpFramesAmount * 2;
|
interpFramesAmount = interpFramesAmount * 2;
|
||||||
|
|
||||||
//Logger.Log($"Writing out frames for in frame {i} which has {dupesAmount} dupes", true);
|
if (debug) Logger.Log($"Writing out frames for in frame {i} which has {dupesAmount} dupes", true);
|
||||||
// Generate frames file lines
|
// Generate frames file lines
|
||||||
for (int frm = 0; frm < interpFramesAmount; frm++)
|
for (int frm = 0; frm < interpFramesAmount; frm++)
|
||||||
{
|
{
|
||||||
//Logger.Log($"Writing out frame {frm+1}/{interpFramesAmount}", true);
|
if (debug) Logger.Log($"Writing out frame {frm+1}/{interpFramesAmount}", true);
|
||||||
|
|
||||||
|
|
||||||
if (discardThisFrame && totalFileCount > 1) // If frame is scene cut frame
|
if (discardThisFrame && totalFileCount > 1) // If frame is scene cut frame
|
||||||
{
|
{
|
||||||
int lastNum = totalFileCount;
|
int lastNum = totalFileCount;
|
||||||
|
|
||||||
//Logger.Log($"Writing frame {totalFileCount} [Discarding Next]", true);
|
if (debug) Logger.Log($"Writing frame {totalFileCount} [Discarding Next]", true);
|
||||||
fileContent += $"file '{interpPath}/{totalFileCount.ToString().PadLeft(Padding.interpFrames, '0')}.{ext}'\n";
|
fileContent += $"file '{interpPath}/{totalFileCount.ToString().PadLeft(Padding.interpFrames, '0')}.{ext}'\n";
|
||||||
totalFileCount++;
|
totalFileCount++;
|
||||||
|
|
||||||
//Logger.Log("Discarding interp frames with out num " + totalFileCount);
|
if (debug) Logger.Log("Discarding interp frames with out num " + totalFileCount);
|
||||||
for (int dupeCount = 1; dupeCount < interpFramesAmount; dupeCount++)
|
for (int dupeCount = 1; dupeCount < interpFramesAmount; dupeCount++)
|
||||||
{
|
{
|
||||||
//Logger.Log($"Writing frame {totalFileCount} which is actually repeated frame {lastNum}");
|
if (debug) Logger.Log($"Writing frame {totalFileCount} which is actually repeated frame {lastNum}");
|
||||||
fileContent += $"file '{interpPath}/{lastNum.ToString().PadLeft(Padding.interpFrames, '0')}.{ext}'\n";
|
fileContent += $"file '{interpPath}/{lastNum.ToString().PadLeft(Padding.interpFrames, '0')}.{ext}'\n";
|
||||||
totalFileCount++;
|
totalFileCount++;
|
||||||
}
|
}
|
||||||
@@ -232,7 +234,7 @@ namespace Flowframes.Main
|
|||||||
{
|
{
|
||||||
for(int writtenDupes = -1; writtenDupes < dupesAmount; writtenDupes++) // Write duplicates
|
for(int writtenDupes = -1; writtenDupes < dupesAmount; writtenDupes++) // Write duplicates
|
||||||
{
|
{
|
||||||
//Logger.Log($"Writing frame {totalFileCount}", true, false);
|
if (debug) Logger.Log($"Writing frame {totalFileCount} (writtenDupes {writtenDupes})", true, false);
|
||||||
fileContent += $"file '{interpPath}/{totalFileCount.ToString().PadLeft(Padding.interpFrames, '0')}.{ext}'\n";
|
fileContent += $"file '{interpPath}/{totalFileCount.ToString().PadLeft(Padding.interpFrames, '0')}.{ext}'\n";
|
||||||
}
|
}
|
||||||
totalFileCount++;
|
totalFileCount++;
|
||||||
@@ -261,11 +263,11 @@ namespace Flowframes.Main
|
|||||||
string loopFrameTargetPath = Path.Combine(frameFiles.First().FullName.GetParentDir(), lastFileNumber.ToString().PadLeft(Padding.inputFrames, '0') + $".png");
|
string loopFrameTargetPath = Path.Combine(frameFiles.First().FullName.GetParentDir(), lastFileNumber.ToString().PadLeft(Padding.inputFrames, '0') + $".png");
|
||||||
if (File.Exists(loopFrameTargetPath))
|
if (File.Exists(loopFrameTargetPath))
|
||||||
{
|
{
|
||||||
Logger.Log($"Won't copy loop frame - {Path.GetFileName(loopFrameTargetPath)} already exists.", true);
|
if (debug) Logger.Log($"Won't copy loop frame - {Path.GetFileName(loopFrameTargetPath)} already exists.", true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
File.Copy(frameFiles.First().FullName, loopFrameTargetPath);
|
File.Copy(frameFiles.First().FullName, loopFrameTargetPath);
|
||||||
Logger.Log($"Copied loop frame to {loopFrameTargetPath}.", true);
|
if (debug) Logger.Log($"Copied loop frame to {loopFrameTargetPath}.", true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -122,7 +122,7 @@ namespace Flowframes
|
|||||||
else
|
else
|
||||||
Dedupe.ClearCache();
|
Dedupe.ClearCache();
|
||||||
|
|
||||||
if (Config.GetInt("dedupMode") == 2)
|
if (Config.GetInt("dedupMode") == 2 || Config.GetInt("dedupMode") == 1)
|
||||||
await Dedupe.CreateDupesFileMpdecimate(current.framesFolder, currentInputFrameCount);
|
await Dedupe.CreateDupesFileMpdecimate(current.framesFolder, currentInputFrameCount);
|
||||||
|
|
||||||
if (canceled) return;
|
if (canceled) return;
|
||||||
|
|||||||
@@ -86,7 +86,7 @@ namespace Flowframes.OS
|
|||||||
|
|
||||||
public static bool HasEmbeddedPyFolder ()
|
public static bool HasEmbeddedPyFolder ()
|
||||||
{
|
{
|
||||||
return Directory.Exists(GetPyFolder());
|
return (Directory.Exists(GetPyFolder()) && IOUtils.GetDirSize(GetPyFolder(), false) > 1024 * 1024 * 5);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static string GetPyFolder ()
|
public static string GetPyFolder ()
|
||||||
|
|||||||
Reference in New Issue
Block a user