mirror of
https://github.com/n00mkrad/flowframes.git
synced 2025-12-16 08:27:44 +01:00
Better code for config defaults
This commit is contained in:
4
Code/Forms/SettingsForm.Designer.cs
generated
4
Code/Forms/SettingsForm.Designer.cs
generated
@@ -337,7 +337,7 @@
|
||||
//
|
||||
this.deleteLogsOnStartup.AutoSize = true;
|
||||
this.deleteLogsOnStartup.Location = new System.Drawing.Point(280, 130);
|
||||
this.deleteLogsOnStartup.Name = "deleteLogsOnStartup";
|
||||
this.deleteLogsOnStartup.Name = "delLogsOnStartup";
|
||||
this.deleteLogsOnStartup.Size = new System.Drawing.Size(15, 14);
|
||||
this.deleteLogsOnStartup.TabIndex = 23;
|
||||
this.deleteLogsOnStartup.UseVisualStyleBackColor = true;
|
||||
@@ -1160,7 +1160,7 @@
|
||||
"10",
|
||||
"20"});
|
||||
this.minOutVidLength.Location = new System.Drawing.Point(280, 207);
|
||||
this.minOutVidLength.Name = "minOutVidLength";
|
||||
this.minOutVidLength.Name = "minVidLength";
|
||||
this.minOutVidLength.Size = new System.Drawing.Size(100, 21);
|
||||
this.minOutVidLength.TabIndex = 29;
|
||||
//
|
||||
|
||||
@@ -43,7 +43,7 @@ namespace Flowframes.IO
|
||||
cachedLines = list.ToArray();
|
||||
}
|
||||
|
||||
public static string Get(string key)
|
||||
public static string Get(string key, Type type = Type.String)
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -55,7 +55,7 @@ namespace Flowframes.IO
|
||||
return keyValuePair[1];
|
||||
}
|
||||
}
|
||||
return WriteDefaultValIfExists(key);
|
||||
return WriteDefaultValIfExists(key, type);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
@@ -66,53 +66,51 @@ namespace Flowframes.IO
|
||||
|
||||
public static bool GetBool(string key)
|
||||
{
|
||||
return bool.Parse(Get(key));
|
||||
return bool.Parse(Get(key, Type.Bool));
|
||||
}
|
||||
|
||||
public static int GetInt(string key)
|
||||
{
|
||||
return int.Parse(Get(key));
|
||||
return int.Parse(Get(key, Type.Int));
|
||||
}
|
||||
|
||||
public static float GetFloat(string key)
|
||||
{
|
||||
return float.Parse(Get(key), CultureInfo.InvariantCulture);
|
||||
return float.Parse(Get(key, Type.Float), CultureInfo.InvariantCulture);
|
||||
}
|
||||
|
||||
private static string WriteDefaultValIfExists(string key) // DEFAULTS TO 0, which means key that use 0 as default are not listed here
|
||||
|
||||
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
|
||||
{
|
||||
if (key == "maxVidHeight") return WriteDefault("maxVidHeight", "2160");
|
||||
if (key == "keepTempFolder") return WriteDefault("keepTempFolder", "False");
|
||||
if (key == "deleteLogsOnStartup") return WriteDefault("deleteLogsOnStartup", "True");
|
||||
if (key == "keepFrames") return WriteDefault("keepFrames", "False");
|
||||
if (key == "tempDirCustom") return WriteDefault("tempDirCustom", "C:/");
|
||||
if (key == "maxVidHeight") return WriteDefault(key, "2160");
|
||||
if (key == "delLogsOnStartup") return WriteDefault(key, "True");
|
||||
if (key == "tempDirCustom") return WriteDefault(key, "C:/");
|
||||
// Interpolation
|
||||
if (key == "dedupMode") return WriteDefault("dedupMode", "2");
|
||||
if (key == "dedupThresh") return WriteDefault("dedupThresh", "2");
|
||||
if (key == "enableAudio") return WriteDefault("enableAudio", "True");
|
||||
if (key == "enableLoop") return WriteDefault("enableLoop", "False");
|
||||
if (key == "autoDedupFrames") return WriteDefault("autoDedupFrames", "15");
|
||||
if (key == "vfrDedupe") return WriteDefault("vfrDedupe", "True");
|
||||
if (key == "jpegInterps") return WriteDefault("jpegInterps", "False");
|
||||
if (key == "timingMode") return WriteDefault("timingMode", "1");
|
||||
if (key == "scnDetect") return WriteDefault("scnDetect", "False");
|
||||
if (key == "scnDetectValue") return WriteDefault("scnDetectValue", "0.2");
|
||||
if (key == "dedupMode") return WriteDefault(key, "2");
|
||||
if (key == "dedupThresh") return WriteDefault(key, "2");
|
||||
if (key == "enableAudio") return WriteDefault(key, "True");
|
||||
if (key == "autoDedupFrames") return WriteDefault(key, "15");
|
||||
if (key == "vfrDedupe") return WriteDefault(key, "True");
|
||||
if (key == "timingMode") return WriteDefault(key, "1");
|
||||
if (key == "scnDetectValue") return WriteDefault(key, "0.2");
|
||||
// Video Export
|
||||
if (key == "h264Crf") return WriteDefault("h264Crf", "20");
|
||||
if (key == "h265Crf") return WriteDefault("h265Crf", "22");
|
||||
if (key == "gifskiQ") return WriteDefault("gifskiQ", "95");
|
||||
if (key == "minOutVidLength") return WriteDefault("minOutVidLength", "2");
|
||||
if (key == "h264Crf") return WriteDefault(key, "20");
|
||||
if (key == "h265Crf") return WriteDefault(key, "22");
|
||||
if (key == "gifskiQ") return WriteDefault(key, "95");
|
||||
if (key == "minVidLength") return WriteDefault(key, "2");
|
||||
// AI
|
||||
if (key == "rifeMode") return WriteDefault("rifeMode", ((NvApi.GetVramGb() > 5f) ? 1 : 0).ToString()); // Enable by default if GPU has >5gb VRAM
|
||||
if (key == "ncnnThreads") return WriteDefault("ncnnThreads", "2");
|
||||
if (key == "rifeMode") return WriteDefault(key, ((NvApi.GetVramGb() > 7f) ? 1 : 0).ToString()); // Enable by default if GPU has >7gb VRAM
|
||||
if (key == "ncnnThreads") return WriteDefault(key, "1");
|
||||
// Debug / Other / Experimental
|
||||
if (key == "ffprobeCountFrames") return WriteDefault("ffprobeCountFrames", "False");
|
||||
if (key == "ffEncPreset") return WriteDefault("ffEncPreset", "medium");
|
||||
if (key == "ffEncPreset") return WriteDefault("ffEncPreset", "medium");
|
||||
if (key == "ffEncPreset") return WriteDefault(key, "medium");
|
||||
// Tile Sizes
|
||||
if (key == "tilesize_RIFE_NCNN") return WriteDefault("tilesize_RIFE_NCNN", "2048");
|
||||
if (key == "tilesize_DAIN_NCNN") return WriteDefault("tilesize_DAIN_NCNN", "512");
|
||||
if (key == "tilesize_CAIN_NCNN") return WriteDefault("tilesize_CAIN_NCNN", "2048");
|
||||
if (key == "tilesize_RIFE_NCNN") return WriteDefault(key, "2048");
|
||||
if (key == "tilesize_DAIN_NCNN") return WriteDefault(key, "512");
|
||||
if (key == "tilesize_CAIN_NCNN") return WriteDefault(key, "2048");
|
||||
|
||||
if (type == Type.Int || type == Type.Float) return WriteDefault(key, "0"); // Write default int/float (0)
|
||||
if (type == Type.Bool) return WriteDefault(key, "False"); // Write default bool (False)
|
||||
return WriteDefault(key, "0");
|
||||
}
|
||||
|
||||
|
||||
@@ -54,7 +54,7 @@ namespace Flowframes.IO
|
||||
|
||||
public static void LoadGuiElement(CheckBox checkbox)
|
||||
{
|
||||
checkbox.Checked = bool.Parse(Config.Get(checkbox.Name));
|
||||
checkbox.Checked = Config.GetBool(checkbox.Name);
|
||||
}
|
||||
|
||||
public static void LoadComboxIndex(ComboBox comboBox)
|
||||
|
||||
@@ -108,7 +108,7 @@ namespace Flowframes.Main
|
||||
static int GetLoopTimes(string framesOutPath)
|
||||
{
|
||||
int times = -1;
|
||||
int minLength = Config.GetInt("minOutVidLength");
|
||||
int minLength = Config.GetInt("minVidLength");
|
||||
int minFrameCount = (minLength * i.currentOutFps).RoundToInt();
|
||||
int outFrames = new DirectoryInfo(framesOutPath).GetFiles($"*.{InterpolateUtils.lastExt}", SearchOption.TopDirectoryOnly).Length;
|
||||
if (outFrames / i.currentOutFps < minLength)
|
||||
|
||||
@@ -29,7 +29,7 @@ namespace Flowframes
|
||||
Paths.Init();
|
||||
Config.Init();
|
||||
|
||||
if (Config.GetBool("deleteLogsOnStartup"))
|
||||
if (Config.GetBool("delLogsOnStartup"))
|
||||
IOUtils.DeleteContentsOfDir(Paths.GetLogPath()); // Clear out older logs not from this session
|
||||
|
||||
string oldExePath = IOUtils.GetExe() + ".old";
|
||||
|
||||
@@ -42,10 +42,10 @@ namespace Flowframes.UI
|
||||
if (span.TotalMinutes >= 1f)
|
||||
return span.ToString(@"mm\:ss");
|
||||
|
||||
if (span.TotalSeconds >= 3f)
|
||||
if (span.TotalSeconds >= 2f)
|
||||
return span.ToString(@"ss") + "s";
|
||||
|
||||
return span.Milliseconds.ToString() + "ms";
|
||||
return span.Milliseconds + "ms";
|
||||
}
|
||||
|
||||
public static string TimeSw(Stopwatch sw)
|
||||
|
||||
Reference in New Issue
Block a user