mirror of https://github.com/n00mkrad/flowframes
Fixed scene detection, removed cain tilesize, autoenc option, loop times fix
This commit is contained in:
parent
4010c0b948
commit
ffe669280e
|
@ -36,7 +36,7 @@ namespace Flowframes
|
|||
string sizeStr = (size.Width > 1 && size.Height > 1) ? $"-s {size.Width}x{size.Height}" : "";
|
||||
IOUtils.CreateDir(frameFolderPath);
|
||||
string timecodeStr = timecodes ? "-copyts -r 1000 -frame_pts true" : "";
|
||||
string scnDetect = sceneDetect ? $"\"select='gt(scene,{Config.Get("scnDetectValue")})'\"," : "";
|
||||
string scnDetect = sceneDetect ? $"\"select='gt(scene,{Config.GetFloatString("scnDetectValue")})'\"," : "";
|
||||
string pad = Padding.inputFrames.ToString();
|
||||
string args = $"-i {inputFile.Wrap()} {pngComprArg} -vsync 0 -pix_fmt rgb24 {timecodeStr} -vf {scnDetect}{divisionFilter} {sizeStr} \"{frameFolderPath}/%{pad}d.png\"";
|
||||
if (deDupe)
|
||||
|
|
|
@ -141,6 +141,9 @@
|
|||
this.cmdDebugMode = new System.Windows.Forms.ComboBox();
|
||||
this.titleLabel = new System.Windows.Forms.Label();
|
||||
this.toolTip1 = new System.Windows.Forms.ToolTip(this.components);
|
||||
this.panel14 = new System.Windows.Forms.Panel();
|
||||
this.label49 = new System.Windows.Forms.Label();
|
||||
this.autoEncMode = new System.Windows.Forms.ComboBox();
|
||||
this.settingsTabList.SuspendLayout();
|
||||
this.generalTab.SuspendLayout();
|
||||
this.tabListPage2.SuspendLayout();
|
||||
|
@ -354,6 +357,9 @@
|
|||
// tabListPage2
|
||||
//
|
||||
this.tabListPage2.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(48)))), ((int)(((byte)(48)))), ((int)(((byte)(48)))));
|
||||
this.tabListPage2.Controls.Add(this.autoEncMode);
|
||||
this.tabListPage2.Controls.Add(this.label49);
|
||||
this.tabListPage2.Controls.Add(this.panel14);
|
||||
this.tabListPage2.Controls.Add(this.label52);
|
||||
this.tabListPage2.Controls.Add(this.scnDetectValue);
|
||||
this.tabListPage2.Controls.Add(this.label51);
|
||||
|
@ -382,7 +388,7 @@
|
|||
//
|
||||
this.label52.AutoSize = true;
|
||||
this.label52.ForeColor = System.Drawing.Color.Silver;
|
||||
this.label52.Location = new System.Drawing.Point(482, 161);
|
||||
this.label52.Location = new System.Drawing.Point(509, 162);
|
||||
this.label52.Margin = new System.Windows.Forms.Padding(10, 10, 10, 7);
|
||||
this.label52.Name = "label52";
|
||||
this.label52.Size = new System.Drawing.Size(225, 13);
|
||||
|
@ -392,7 +398,6 @@
|
|||
// scnDetectValue
|
||||
//
|
||||
this.scnDetectValue.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(64)))), ((int)(((byte)(64)))), ((int)(((byte)(64)))));
|
||||
this.scnDetectValue.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
|
||||
this.scnDetectValue.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
|
||||
this.scnDetectValue.ForeColor = System.Drawing.Color.White;
|
||||
this.scnDetectValue.FormattingEnabled = true;
|
||||
|
@ -565,7 +570,7 @@
|
|||
//
|
||||
this.label27.AutoSize = true;
|
||||
this.label27.ForeColor = System.Drawing.Color.Silver;
|
||||
this.label27.Location = new System.Drawing.Point(308, 251);
|
||||
this.label27.Location = new System.Drawing.Point(308, 271);
|
||||
this.label27.Margin = new System.Windows.Forms.Padding(10, 10, 10, 7);
|
||||
this.label27.Name = "label27";
|
||||
this.label27.Size = new System.Drawing.Size(449, 13);
|
||||
|
@ -576,7 +581,7 @@
|
|||
// jpegInterps
|
||||
//
|
||||
this.jpegInterps.AutoSize = true;
|
||||
this.jpegInterps.Location = new System.Drawing.Point(280, 250);
|
||||
this.jpegInterps.Location = new System.Drawing.Point(280, 270);
|
||||
this.jpegInterps.Name = "jpegInterps";
|
||||
this.jpegInterps.Size = new System.Drawing.Size(15, 14);
|
||||
this.jpegInterps.TabIndex = 48;
|
||||
|
@ -585,7 +590,7 @@
|
|||
// label25
|
||||
//
|
||||
this.label25.AutoSize = true;
|
||||
this.label25.Location = new System.Drawing.Point(10, 250);
|
||||
this.label25.Location = new System.Drawing.Point(10, 270);
|
||||
this.label25.Margin = new System.Windows.Forms.Padding(10, 10, 10, 7);
|
||||
this.label25.Name = "label25";
|
||||
this.label25.Size = new System.Drawing.Size(149, 13);
|
||||
|
@ -596,7 +601,7 @@
|
|||
//
|
||||
this.label26.AutoSize = true;
|
||||
this.label26.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Bold);
|
||||
this.label26.Location = new System.Drawing.Point(10, 220);
|
||||
this.label26.Location = new System.Drawing.Point(10, 240);
|
||||
this.label26.Margin = new System.Windows.Forms.Padding(10, 10, 10, 7);
|
||||
this.label26.Name = "label26";
|
||||
this.label26.Size = new System.Drawing.Size(76, 16);
|
||||
|
@ -1523,6 +1528,42 @@
|
|||
this.titleLabel.TabIndex = 1;
|
||||
this.titleLabel.Text = "Settings";
|
||||
//
|
||||
// panel14
|
||||
//
|
||||
this.panel14.BackgroundImage = global::Flowframes.Properties.Resources.baseline_create_white_18dp_semiTransparent;
|
||||
this.panel14.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Zoom;
|
||||
this.panel14.Location = new System.Drawing.Point(475, 157);
|
||||
this.panel14.Name = "panel14";
|
||||
this.panel14.Size = new System.Drawing.Size(21, 21);
|
||||
this.panel14.TabIndex = 68;
|
||||
this.toolTip1.SetToolTip(this.panel14, "Allows custom input.");
|
||||
//
|
||||
// label49
|
||||
//
|
||||
this.label49.AutoSize = true;
|
||||
this.label49.Location = new System.Drawing.Point(10, 190);
|
||||
this.label49.Margin = new System.Windows.Forms.Padding(10, 10, 10, 7);
|
||||
this.label49.Name = "label49";
|
||||
this.label49.Size = new System.Drawing.Size(206, 13);
|
||||
this.label49.TabIndex = 69;
|
||||
this.label49.Text = "Auto-Encode (Encode While Interpolating)";
|
||||
//
|
||||
// autoEncMode
|
||||
//
|
||||
this.autoEncMode.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(64)))), ((int)(((byte)(64)))), ((int)(((byte)(64)))));
|
||||
this.autoEncMode.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
|
||||
this.autoEncMode.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
|
||||
this.autoEncMode.ForeColor = System.Drawing.Color.White;
|
||||
this.autoEncMode.FormattingEnabled = true;
|
||||
this.autoEncMode.Items.AddRange(new object[] {
|
||||
"Disabled",
|
||||
"Enabled (Keep Interpolated Frames)",
|
||||
"Enabled (Delete Frames Once Encoded)"});
|
||||
this.autoEncMode.Location = new System.Drawing.Point(280, 187);
|
||||
this.autoEncMode.Name = "autoEncMode";
|
||||
this.autoEncMode.Size = new System.Drawing.Size(250, 21);
|
||||
this.autoEncMode.TabIndex = 70;
|
||||
//
|
||||
// SettingsForm
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
|
@ -1672,5 +1713,8 @@
|
|||
private System.Windows.Forms.Label label54;
|
||||
private System.Windows.Forms.ComboBox loopMode;
|
||||
private System.Windows.Forms.Label label55;
|
||||
private System.Windows.Forms.Panel panel14;
|
||||
private System.Windows.Forms.Label label49;
|
||||
private System.Windows.Forms.ComboBox autoEncMode;
|
||||
}
|
||||
}
|
|
@ -61,7 +61,8 @@ namespace Flowframes.Forms
|
|||
ConfigParser.SaveGuiElement(enableLoop);
|
||||
ConfigParser.SaveGuiElement(jpegInterps);
|
||||
ConfigParser.SaveGuiElement(scnDetect);
|
||||
ConfigParser.SaveGuiElement(scnDetectValue);
|
||||
ConfigParser.SaveGuiElement(scnDetectValue, ConfigParser.StringMode.Float);
|
||||
ConfigParser.SaveComboxIndex(autoEncMode);
|
||||
// AI
|
||||
ConfigParser.SaveComboxIndex(rifeMode);
|
||||
ConfigParser.SaveGuiElement(torchGpus);
|
||||
|
@ -106,6 +107,7 @@ namespace Flowframes.Forms
|
|||
ConfigParser.LoadGuiElement(jpegInterps);
|
||||
ConfigParser.LoadGuiElement(scnDetect);
|
||||
ConfigParser.LoadGuiElement(scnDetectValue);
|
||||
ConfigParser.LoadComboxIndex(autoEncMode);
|
||||
// AI
|
||||
ConfigParser.LoadComboxIndex(rifeMode);
|
||||
ConfigParser.LoadGuiElement(torchGpus);
|
||||
|
|
|
@ -79,9 +79,13 @@ namespace Flowframes.IO
|
|||
return float.Parse(Get(key, Type.Float), CultureInfo.InvariantCulture);
|
||||
}
|
||||
|
||||
public static string GetFloatString (string key)
|
||||
{
|
||||
return Get(key, Type.Float).Replace(",", ".");
|
||||
}
|
||||
|
||||
public enum Type { String, Int, Float, Bool }
|
||||
private static string WriteDefaultValIfExists(string key, Type type) // DEFAULTS TO 0, which means key that use 0 as default are not listed here
|
||||
private static string WriteDefaultValIfExists(string key, Type type)
|
||||
{
|
||||
if (key == "maxVidHeight") return WriteDefault(key, "2160");
|
||||
if (key == "delLogsOnStartup") return WriteDefault(key, "True");
|
||||
|
@ -94,6 +98,7 @@ namespace Flowframes.IO
|
|||
if (key == "vfrDedupe") return WriteDefault(key, "True");
|
||||
if (key == "timingMode") return WriteDefault(key, "1");
|
||||
if (key == "scnDetectValue") return WriteDefault(key, "0.2");
|
||||
if (key == "autoEncMode") return WriteDefault(key, "2");
|
||||
// Video Export
|
||||
if (key == "h264Crf") return WriteDefault(key, "20");
|
||||
if (key == "h265Crf") return WriteDefault(key, "22");
|
||||
|
|
|
@ -70,8 +70,11 @@ namespace Flowframes.Main
|
|||
|
||||
if(Interpolate.canceled) return;
|
||||
|
||||
foreach (string frame in framesToEncode)
|
||||
File.WriteAllText(frame, "THIS IS A DUMMY FILE - DO NOT DELETE ME"); // Overwrite to save disk space without breaking progress counter
|
||||
if (Config.GetInt("autoEncMode") == 2)
|
||||
{
|
||||
foreach (string frame in framesToEncode)
|
||||
File.WriteAllText(frame, "THIS IS A DUMMY FILE - DO NOT DELETE ME"); // Overwrite to save space without breaking progress counter
|
||||
}
|
||||
|
||||
encodedFrames.AddRange(framesToEncode);
|
||||
|
||||
|
|
|
@ -20,6 +20,7 @@ namespace Flowframes.Main
|
|||
{
|
||||
public static async Task Export(string path, string outPath, i.OutMode mode)
|
||||
{
|
||||
Logger.Log("Auto-Encode is off, exporting video...");
|
||||
if (!mode.ToString().ToLower().Contains("vid")) // Copy interp frames out of temp folder and skip video export for image seq export
|
||||
{
|
||||
try
|
||||
|
@ -191,7 +192,8 @@ namespace Flowframes.Main
|
|||
//Logger.Log("minLength: " + minLength);
|
||||
int minFrameCount = (minLength * i.currentOutFps).RoundToInt();
|
||||
//Logger.Log("minFrameCount: " + minFrameCount);
|
||||
int outFrames = new DirectoryInfo(framesOutPath).GetFiles($"*.{InterpolateUtils.lastExt}", SearchOption.TopDirectoryOnly).Length;
|
||||
//int outFrames = new DirectoryInfo(framesOutPath).GetFiles($"*.{InterpolateUtils.lastExt}", SearchOption.TopDirectoryOnly).Length;
|
||||
int outFrames = i.currentInputFrameCount * i.lastInterpFactor;
|
||||
//Logger.Log("outFrames: " + outFrames);
|
||||
if (outFrames / i.currentOutFps < minLength)
|
||||
times = (int)Math.Ceiling((double)minFrameCount / (double)outFrames);
|
||||
|
|
|
@ -28,6 +28,7 @@ namespace Flowframes
|
|||
public static int interpFactor;
|
||||
public static float currentInFps;
|
||||
public static float currentOutFps;
|
||||
public static int currentInputFrameCount;
|
||||
public static OutMode currentOutMode;
|
||||
public static bool currentInputIsFrames;
|
||||
public static bool currentlyUsingAutoEnc;
|
||||
|
@ -143,10 +144,9 @@ namespace Flowframes
|
|||
|
||||
public static async Task PostProcessFrames (bool sbsMode = false)
|
||||
{
|
||||
//bool firstFrameFix = (!sbsMode && lastAi.aiName == Networks.rifeCuda.aiName) || (sbsMode && InterpolateSteps.currentAi.aiName == Networks.rifeCuda.aiName);
|
||||
//firstFrameFix = false; // TODO: Remove firstframefix if new rife code works
|
||||
currentInputFrameCount = IOUtils.GetAmountOfFiles(currentFramesPath, false, "*.png");
|
||||
|
||||
if (!Directory.Exists(currentFramesPath) || IOUtils.GetAmountOfFiles(currentFramesPath, false, "*.png") <= 0)
|
||||
if (!Directory.Exists(currentFramesPath) || currentInputFrameCount <= 0)
|
||||
Cancel("Input frames folder is empty!");
|
||||
|
||||
if (Config.GetInt("dedupMode") == 1)
|
||||
|
@ -170,9 +170,8 @@ namespace Flowframes
|
|||
|
||||
public static async Task RunAi(string outpath, int targetFrames, int tilesize, AI ai)
|
||||
{
|
||||
currentlyUsingAutoEnc = IOUtils.GetAmountOfFiles(currentFramesPath, false) * lastInterpFactor >= (AutoEncode.chunkSize + AutoEncode.safetyBufferFrames) * 1.2f;
|
||||
//Logger.Log("Using autoenc if there's more than " + (AutoEncode.chunkSize + AutoEncode.safetyBufferFrames) * 1.2f + " input frames, got " + IOUtils.GetAmountOfFiles(currentFramesPath, false) * lastInterpFactor);
|
||||
//currentlyUsingAutoEnc = false;
|
||||
if(Config.GetInt("autoEncMode") > 0)
|
||||
currentlyUsingAutoEnc = IOUtils.GetAmountOfFiles(currentFramesPath, false) * lastInterpFactor >= (AutoEncode.chunkSize + AutoEncode.safetyBufferFrames) * 1.1f;
|
||||
|
||||
Directory.CreateDirectory(outpath);
|
||||
|
||||
|
@ -190,8 +189,11 @@ namespace Flowframes
|
|||
if (ai.aiName == Networks.rifeNcnn.aiName)
|
||||
tasks.Add(AiProcess.RunRifeNcnnMulti(currentFramesPath, outpath, tilesize, interpFactor));
|
||||
|
||||
if(currentlyUsingAutoEnc)
|
||||
if (currentlyUsingAutoEnc)
|
||||
{
|
||||
Logger.Log("Using Auto-Encode.");
|
||||
tasks.Add(AutoEncode.MainLoop(outpath));
|
||||
}
|
||||
await Task.WhenAll(tasks);
|
||||
}
|
||||
|
||||
|
|
|
@ -112,27 +112,27 @@ namespace Flowframes.Main
|
|||
|
||||
bool isFile = !IOUtils.IsPathDirectory(inDir);
|
||||
|
||||
if ((isFile && !IOUtils.IsFileValid(inDir)) || (!isFile && !IOUtils.IsDirValid(inDir)))
|
||||
if ((passes && isFile && !IOUtils.IsFileValid(inDir)) || (!isFile && !IOUtils.IsDirValid(inDir)))
|
||||
{
|
||||
ShowMessage("Input path is not valid!");
|
||||
passes = false;
|
||||
}
|
||||
if (!IOUtils.IsDirValid(outDir))
|
||||
if (passes && !IOUtils.IsDirValid(outDir))
|
||||
{
|
||||
ShowMessage("Output path is not valid!");
|
||||
passes = false;
|
||||
}
|
||||
if (interp != 2 && interp != 4 && interp != 8)
|
||||
if (passes && interp != 2 && interp != 4 && interp != 8)
|
||||
{
|
||||
ShowMessage("Interpolation factor is not valid!");
|
||||
passes = false;
|
||||
}
|
||||
if (fpsOut < 1 || fpsOut > 500)
|
||||
if (passes && fpsOut < 1 || fpsOut > 500)
|
||||
{
|
||||
ShowMessage("Invalid target frame rate - Must be 1-500.");
|
||||
passes = false;
|
||||
}
|
||||
if (tilesize % 32 != 0 || tilesize < 128)
|
||||
if (passes && tilesize % 32 != 0 || tilesize < 128)
|
||||
{
|
||||
ShowMessage("Tile size is not valid - Must be a multiple of 32 and at least 128!");
|
||||
passes = false;
|
||||
|
|
|
@ -83,24 +83,38 @@ namespace Flowframes.Main
|
|||
if (loopEnabled && i == (frameFiles.Length - 2))
|
||||
interpFramesAmount = interpFramesAmount * 2;
|
||||
|
||||
// Logger.Log("Writing out frames for in frame " + i);
|
||||
// Generate frames file lines
|
||||
for (int frm = 0; frm < interpFramesAmount; frm++)
|
||||
{
|
||||
// Logger.Log($"Writing out frame {frm+1}/{interpFramesAmount}", true);
|
||||
|
||||
string durationStr = ((durationPerInterpFrame / 1000f) * 1).ToString("0.00000", CultureInfo.InvariantCulture);
|
||||
|
||||
if (discardThisFrame && totalFileCount > 1) // Never discard 1st frame
|
||||
{
|
||||
int lastNum = totalFileCount - 1;
|
||||
int lastNum = totalFileCount;
|
||||
|
||||
// Logger.Log($"Writing frame {totalFileCount} [Discarding Next]", true);
|
||||
fileContent += $"file '{interpPath}/{totalFileCount.ToString().PadLeft(Padding.interpFrames, '0')}.png'\nduration {durationStr}\n";
|
||||
totalFileCount++;
|
||||
|
||||
// Logger.Log("Discarding interp frames with out num " + totalFileCount);
|
||||
for (int dupeCount = 1; dupeCount < interpFramesAmount; dupeCount++)
|
||||
{
|
||||
// Logger.Log($"Writing frame {totalFileCount} which is actually repeated frame {lastNum}");
|
||||
fileContent += $"file '{interpPath}/{lastNum.ToString().PadLeft(Padding.interpFrames, '0')}.png'\nduration {durationStr}\n";
|
||||
totalFileCount++;
|
||||
}
|
||||
frm = interpFramesAmount - 1;
|
||||
}
|
||||
|
||||
fileContent += $"file '{interpPath}/{totalFileCount.ToString().PadLeft(Padding.interpFrames, '0')}.png'\nduration {durationStr}\n";
|
||||
totalFileCount++;
|
||||
frm = interpFramesAmount;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Logger.Log($"Writing frame {totalFileCount}", true, false);
|
||||
fileContent += $"file '{interpPath}/{totalFileCount.ToString().PadLeft(Padding.interpFrames, '0')}.png'\nduration {durationStr}\n";
|
||||
totalFileCount++;
|
||||
}
|
||||
}
|
||||
|
||||
if ((i + 1) % 100 == 0)
|
||||
|
|
|
@ -83,7 +83,7 @@ namespace Flowframes
|
|||
processTimeMulti.Restart();
|
||||
Logger.Log("Running CAIN...", false);
|
||||
|
||||
string args = $" -v -i {framesPath.Wrap()} -o {outPath.Wrap()} -t {tilesize} -g {Config.Get("ncnnGpus")}";
|
||||
string args = $" -v -i {framesPath.Wrap()} -o {outPath.Wrap()} -g {Config.Get("ncnnGpus")}";
|
||||
await RunCainPartial(args);
|
||||
|
||||
if(times == 4 || times == 8) // #2
|
||||
|
@ -94,7 +94,7 @@ namespace Flowframes
|
|||
IOUtils.TryDeleteIfExists(run1ResultsPath);
|
||||
Directory.Move(outPath, run1ResultsPath);
|
||||
Directory.CreateDirectory(outPath);
|
||||
args = $" -v -i {run1ResultsPath.Wrap()} -o {outPath.Wrap()} -t {tilesize} -g {Config.Get("ncnnGpus")}";
|
||||
args = $" -v -i {run1ResultsPath.Wrap()} -o {outPath.Wrap()} -g {Config.Get("ncnnGpus")}";
|
||||
await RunCainPartial(args);
|
||||
IOUtils.TryDeleteIfExists(run1ResultsPath);
|
||||
}
|
||||
|
@ -107,7 +107,7 @@ namespace Flowframes
|
|||
IOUtils.TryDeleteIfExists(run2ResultsPath);
|
||||
Directory.Move(outPath, run2ResultsPath);
|
||||
Directory.CreateDirectory(outPath);
|
||||
args = $" -v -i {run2ResultsPath.Wrap()} -o {outPath.Wrap()} -t {tilesize} -g {Config.Get("ncnnGpus")}";
|
||||
args = $" -v -i {run2ResultsPath.Wrap()} -o {outPath.Wrap()} -g {Config.Get("ncnnGpus")}";
|
||||
await RunCainPartial(args);
|
||||
IOUtils.TryDeleteIfExists(run2ResultsPath);
|
||||
}
|
||||
|
@ -159,7 +159,7 @@ namespace Flowframes
|
|||
}
|
||||
|
||||
Process rifePy = OSUtils.NewProcess(!OSUtils.ShowHiddenCmd());
|
||||
AiStarted(rifePy, 3000, "png");
|
||||
AiStarted(rifePy, 3250, "png");
|
||||
rifePy.StartInfo.Arguments = $"{OSUtils.GetCmdArg()} cd /D {PkgUtils.GetPkgFolder(Packages.rifeCuda).Wrap()} & " +
|
||||
$"set CUDA_VISIBLE_DEVICES={Config.Get("torchGpus")} & {Pytorch.GetPyCmd()} {script} {args} --imgformat {InterpolateUtils.lastExt} --output {Paths.interpDir}";
|
||||
Logger.Log($"Running RIFE ({script})...", false);
|
||||
|
|
Loading…
Reference in New Issue