static async Task RunEntry(InterpSettings entry) { if (!EntryIsValid(entry)) { Logger.Log("[Queue] Skipping entry because it's invalid."); Program.batchQueue.Dequeue(); return; } string fname = Path.GetFileName(entry.inPath); if (IOUtils.IsPathDirectory(entry.inPath)) { fname = Path.GetDirectoryName(entry.inPath); } Logger.Log($"[Queue] Processing {fname} ({entry.interpFactor}x {entry.ai.aiNameShort})."); SetBusy(true); Program.mainForm.LoadBatchEntry(entry); // Load entry into GUI Interpolate.current = entry; Program.mainForm.runBtn_Click(null, null); await Task.Delay(2000); while (Program.busy) { await Task.Delay(1000); } SetBusy(false); Program.batchQueue.Dequeue(); Logger.Log($"[Queue] Done processing {fname} ({entry.interpFactor}x {entry.ai.aiNameShort})."); }
public static void LoadTempFolder(string tempFolderPath) { string resumeFolderPath = Path.Combine(tempFolderPath, Paths.resumeDir); string interpSettingsPath = Path.Combine(resumeFolderPath, interpSettingsFilename); InterpSettings interpSettings = new InterpSettings(File.ReadAllText(interpSettingsPath)); Program.mainForm.LoadBatchEntry(interpSettings); }
public void RefreshGui() { taskList.Items.Clear(); for (int i = 0; i < Program.batchQueue.Count; i++) { InterpSettings entry = Program.batchQueue.ElementAt(i); string niceOutMode = entry.outMode.ToString().ToUpper().Remove("VID").Remove("IMG"); string str = $"#{i+1}: {Path.GetFileName(entry.inPath).Trunc(40)} - {entry.inFps.GetFloat()} FPS => " + $"{entry.interpFactor}x {entry.ai.aiNameShort} ({entry.model.name}) => {niceOutMode}"; taskList.Items.Add(str); } }
public void RefreshGui() { taskList.Items.Clear(); string nl = Environment.NewLine; for (int i = 0; i < Program.batchQueue.Count; i++) { InterpSettings entry = Program.batchQueue.ElementAt(i); string niceOutMode = entry.outMode.ToString().ToUpper().Replace("VID", "").Replace("IMG", ""); string str = $"#{i}: {Path.GetFileName(entry.inPath).Trunc(45)} - {entry.inFps} FPS => {entry.interpFactor}x{nl} {entry.ai.aiNameShort} => {niceOutMode}"; taskList.Items.Add(str); } }
public static void LoadTempFolder(string tempFolderPath) { try { string resumeFolderPath = Path.Combine(tempFolderPath, Paths.resumeDir); string settingsJsonPath = Path.Combine(resumeFolderPath, interpSettingsFilename); InterpSettings interpSettings = JsonConvert.DeserializeObject <InterpSettings>(File.ReadAllText(settingsJsonPath)); Program.mainForm.LoadBatchEntry(interpSettings); } catch (Exception e) { Logger.Log($"Failed to load resume data: {e.Message}\n{e.StackTrace}"); resumeNextRun = false; } }
public static async Task <string> GetCurrentExportFilename(bool fpsLimit, bool withExt) { InterpSettings curr = Interpolate.current; string max = Config.Get(Config.Key.maxFps); Fraction maxFps = max.Contains("/") ? new Fraction(max) : new Fraction(max.GetFloat()); float fps = fpsLimit ? maxFps.GetFloat() : curr.outFps.GetFloat(); if (curr.outMode == Interpolate.OutMode.VidGif && fps > 50f) { fps = 50f; } Size outRes = await InterpolateUtils.GetOutputResolution(curr.inPath, false, false); string pattern = Config.Get(Config.Key.exportNamePattern); string inName = Interpolate.current.inputIsFrames ? Path.GetFileName(curr.inPath) : Path.GetFileNameWithoutExtension(curr.inPath); bool encodeBoth = Config.GetInt(Config.Key.maxFpsMode) == 0; bool addSuffix = fpsLimit && (!pattern.Contains("[FPS]") && !pattern.Contains("[ROUNDFPS]")) && encodeBoth; string filename = pattern; filename = filename.Replace("[NAME]", inName); filename = filename.Replace("[FULLNAME]", Path.GetFileName(curr.inPath)); filename = filename.Replace("[FACTOR]", curr.interpFactor.ToStringDot()); filename = filename.Replace("[AI]", curr.ai.aiNameShort.ToUpper()); filename = filename.Replace("[MODEL]", curr.model.name.Remove(" ")); filename = filename.Replace("[FPS]", fps.ToStringDot()); filename = filename.Replace("[ROUNDFPS]", fps.RoundToInt().ToString()); filename = filename.Replace("[RES]", $"{outRes.Width}x{outRes.Height}"); filename = filename.Replace("[H]", $"{outRes.Height}p"); if (addSuffix) { filename += Paths.fpsLimitSuffix; } if (withExt) { filename += FfmpegUtils.GetExt(curr.outMode); } return(filename); }
static bool EntryIsValid(InterpSettings entry) { if (entry.inPath == null || (IOUtils.IsPathDirectory(entry.inPath) && !Directory.Exists(entry.inPath)) || (!IOUtils.IsPathDirectory(entry.inPath) && !File.Exists(entry.inPath))) { Logger.Log("[Queue] Can't process queue entry: Input path is invalid."); return(false); } if (entry.outPath == null || !Directory.Exists(entry.outPath)) { Logger.Log("[Queue] Can't process queue entry: Output path is invalid."); return(false); } if (!PkgUtils.IsAiAvailable(entry.ai)) { Logger.Log("[Queue] Can't process queue entry: Selected AI is not available."); return(false); } return(true); }
public async Task LoadDroppedPaths(string[] droppedPaths) { foreach (string path in droppedPaths) { Logger.Log($"Dropped file: '{path}'", true); string frame1 = Path.Combine(path, "00000001.png"); if (IOUtils.IsPathDirectory(path) && !File.Exists(frame1)) { InterpolateUtils.ShowMessage($"Can't find frames in this folder:\n\n{frame1} does not exist.", "Error"); continue; } InterpSettings current = Program.mainForm.GetCurrentSettings(); current.UpdatePaths(path, path.GetParentDir()); current.inFps = await GetFramerate(path); current.outFps = current.inFps * current.interpFactor; Program.batchQueue.Enqueue(current); RefreshGui(); await Task.Delay(100); } }
static bool EntryIsValid(InterpSettings entry) { if (entry.inPath == null || (IoUtils.IsPathDirectory(entry.inPath) && !Directory.Exists(entry.inPath)) || (!IoUtils.IsPathDirectory(entry.inPath) && !File.Exists(entry.inPath))) { Logger.Log("Queue: Can't process queue entry: Input path is invalid."); return(false); } if (entry.outPath == null || (!Directory.Exists(entry.outPath) && Config.GetInt("outFolderLoc") != 1)) { Logger.Log("Queue: Can't process queue entry: Output path is invalid."); return(false); } if (IoUtils.GetAmountOfFiles(Path.Combine(Paths.GetPkgPath(), entry.ai.pkgDir), true) < 1) { Logger.Log("Queue: Can't process queue entry: Selected AI is not available."); return(false); } return(true); }
public static bool CanUseAutoEnc(bool stepByStep, InterpSettings current) { AutoEncode.UpdateChunkAndBufferSizes(); if (Config.GetInt(Config.Key.cmdDebugMode) > 0) { Logger.Log($"Not Using AutoEnc: CMD window is shown (cmdDebugMode > 0)", true); return(false); } if (current.outMode == I.OutMode.VidGif) { Logger.Log($"Not Using AutoEnc: Using GIF output", true); return(false); } if (stepByStep && !Config.GetBool(Config.Key.sbsAllowAutoEnc)) { Logger.Log($"Not Using AutoEnc: Using step-by-step mode, but 'sbsAllowAutoEnc' is false", true); return(false); } if (!stepByStep && Config.GetInt(Config.Key.autoEncMode) == 0) { Logger.Log($"Not Using AutoEnc: 'autoEncMode' is 0", true); return(false); } int inFrames = IoUtils.GetAmountOfFiles(current.framesFolder, false); if (inFrames * current.interpFactor < (AutoEncode.chunkSize + AutoEncode.safetyBufferFrames) * 1.2f) { Logger.Log($"Not Using AutoEnc: Input frames ({inFrames}) * factor ({current.interpFactor}) is smaller than (chunkSize ({AutoEncode.chunkSize}) + safetyBufferFrames ({AutoEncode.safetyBufferFrames}) * 1.2f)", true); return(false); } return(true); }
public static bool CanUseAutoEnc(bool stepByStep, InterpSettings current) { AutoEncode.UpdateChunkAndBufferSizes(); if (current.alpha) { Logger.Log($"Not Using AutoEnc: Alpha mode is enabled.", true); return(false); } if (!current.outMode.ToString().ToLower().Contains("vid") || current.outMode.ToString().ToLower().Contains("gif")) { Logger.Log($"Not Using AutoEnc: Out Mode is not video ({current.outMode.ToString()})", true); return(false); } if (stepByStep && !Config.GetBool("sbsAllowAutoEnc")) { Logger.Log($"Not Using AutoEnc: Using step-by-step mode, but 'sbsAllowAutoEnc' is false.", true); return(false); } if (!stepByStep && Config.GetInt("autoEncMode") == 0) { Logger.Log($"Not Using AutoEnc: 'autoEncMode' is 0.", true); return(false); } int inFrames = IOUtils.GetAmountOfFiles(current.framesFolder, false); if (inFrames * current.interpFactor < (AutoEncode.chunkSize + AutoEncode.safetyBufferFrames) * 1.2f) { Logger.Log($"Not Using AutoEnc: Input frames ({inFrames}) * factor ({current.interpFactor}) is smaller than (chunkSize ({AutoEncode.chunkSize}) + safetyBufferFrames ({AutoEncode.safetyBufferFrames}) * 1.2f)", true); return(false); } return(true); }
public async Task LoadDroppedPaths(string[] droppedPaths, bool start = false) { foreach (string path in droppedPaths) { Logger.Log($"BatchForm: Dropped path: '{path}'", true); InterpSettings current = Program.mainForm.GetCurrentSettings(); string outDir = (Config.GetInt("outFolderLoc") == 0) ? path.GetParentDir() : Config.Get("custOutDir").Trim(); current.UpdatePaths(path, outDir); current.inFpsDetected = await IoUtils.GetFpsFolderOrVideo(path); current.inFps = current.inFpsDetected; current.outFps = current.inFps * current.interpFactor; Program.batchQueue.Enqueue(current); RefreshGui(); } if (start) { runBtn_Click(null, null); } }