diff --git a/Code/AudioVideo/AvProcess.cs b/Code/AudioVideo/AvProcess.cs index 28f5d06..f4fa1fb 100644 --- a/Code/AudioVideo/AvProcess.cs +++ b/Code/AudioVideo/AvProcess.cs @@ -51,16 +51,14 @@ namespace Flowframes if (outLine == null || outLine.Data == null) return; string line = outLine.Data; - lastOutputFfmpeg = lastOutputFfmpeg + line + "\n"; + lastOutputFfmpeg = lastOutputFfmpeg + "\n" + line; bool hidden = currentLogMode == LogMode.Hidden; bool replaceLastLine = currentLogMode == LogMode.OnlyLastLine; string trimmedLine = line.Remove("q=-0.0").Remove("size=N/A").Remove("bitrate=N/A").TrimWhitespaces(); Logger.Log(trimmedLine, hidden, replaceLastLine, "ffmpeg"); if(line.Contains("Could not open file")) - { - Interpolate.Cancel("Failed to write frames - Make sure the folder is not restricted!"); - } + Interpolate.Cancel($"FFmpeg Error: {line}"); } static void FfmpegOutputHandlerSilent (object sendingProcess, DataReceivedEventArgs outLine) diff --git a/Code/AudioVideo/FFmpegCommands.cs b/Code/AudioVideo/FFmpegCommands.cs index aabc0aa..de31d55 100644 --- a/Code/AudioVideo/FFmpegCommands.cs +++ b/Code/AudioVideo/FFmpegCommands.cs @@ -114,7 +114,7 @@ namespace Flowframes public static async Task ConcatVideos(string concatFile, string outPath, int looptimes = -1) { - Logger.Log($"Merging videos..."); + Logger.Log($"Merging videos...", false, Logger.GetLastLine().Contains("frame")); string loopStr = (looptimes > 0) ? $"-stream_loop {looptimes}" : ""; string vfrFilename = Path.GetFileName(concatFile); string args = $" {loopStr} -vsync 1 -f concat -i {vfrFilename} -c copy -pix_fmt yuv420p -movflags +faststart {outPath.Wrap()}"; diff --git a/Code/Form1.cs b/Code/Form1.cs index a598957..2e67ab9 100644 --- a/Code/Form1.cs +++ b/Code/Form1.cs @@ -235,6 +235,7 @@ namespace Flowframes public void SetWorking(bool state, bool allowCancel = true) { Logger.Log($"SetWorking({state})", true); + SetProgress(-1); Control[] controlsToDisable = new Control[] { runBtn, runStepBtn, stepSelector, settingsBtn, installerBtn }; Control[] controlsToHide = new Control[] { runBtn, runStepBtn, stepSelector }; progressCircle.Visible = state; diff --git a/Code/IO/Config.cs b/Code/IO/Config.cs index ef3ff25..0f67e6a 100644 --- a/Code/IO/Config.cs +++ b/Code/IO/Config.cs @@ -124,7 +124,7 @@ namespace Flowframes.IO // Video Export if (key == "h264Crf") return WriteDefault(key, "20"); if (key == "h265Crf") return WriteDefault(key, "24"); - if (key == "vp9Crf") return WriteDefault(key, "28"); + if (key == "vp9Crf") return WriteDefault(key, "32"); if (key == "proResProfile") return WriteDefault(key, "2"); if (key == "aviCodec") return WriteDefault(key, "ffv1"); if (key == "aviColors") return WriteDefault(key, "yuv420p"); diff --git a/Code/IO/Logger.cs b/Code/IO/Logger.cs index 77417ca..551a471 100644 --- a/Code/IO/Logger.cs +++ b/Code/IO/Logger.cs @@ -18,7 +18,7 @@ namespace Flowframes public static void Log(string s, bool hidden = false, bool replaceLastLine = false, string filename = "") { - if (s == null) + if (string.IsNullOrWhiteSpace(s)) return; Console.WriteLine(s); @@ -97,5 +97,10 @@ namespace Flowframes string[] lines = textbox.Text.SplitIntoLines(); return lines.Last(); } + + public static void RemoveLastLine () + { + textbox.Text = textbox.Text.Remove(textbox.Text.LastIndexOf(Environment.NewLine)); + } } } diff --git a/Code/Main/FrameTiming.cs b/Code/Main/FrameTiming.cs index 0cd8e60..97cc9e8 100644 --- a/Code/Main/FrameTiming.cs +++ b/Code/Main/FrameTiming.cs @@ -201,7 +201,6 @@ namespace Flowframes.Main 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 - // TODO: Check if this is needed // If loop is enabled, account for the extra frame added to the end for loop continuity if (loopEnabled && i == (frameFiles.Length - 2)) interpFramesAmount = interpFramesAmount * 2; diff --git a/Code/Main/InterpolateUtils.cs b/Code/Main/InterpolateUtils.cs index d84031e..643a929 100644 --- a/Code/Main/InterpolateUtils.cs +++ b/Code/Main/InterpolateUtils.cs @@ -49,6 +49,8 @@ namespace Flowframes.Main string[] frames = IOUtils.GetFilesSorted(outdir, $"*.{GetOutExt()}"); if (frames.Length > 1) UpdateInterpProgress(frames.Length, targetFrames, frames[frames.Length - 1]); + if (frames.Length >= targetFrames) + break; await Task.Delay(GetProgressWaitTime(frames.Length)); } else @@ -56,7 +58,6 @@ namespace Flowframes.Main await Task.Delay(200); } } - Program.mainForm.SetProgress(-1); } public static void UpdateInterpProgress(int frames, int target, string latestFramePath = "") diff --git a/Code/OS/AiProcess.cs b/Code/OS/AiProcess.cs index 0c69949..e623f22 100644 --- a/Code/OS/AiProcess.cs +++ b/Code/OS/AiProcess.cs @@ -40,7 +40,7 @@ namespace Flowframes hasShownError = false; } - static void AiFinished (string aiName) + static async Task AiFinished (string aiName) { Program.mainForm.SetProgress(100); InterpolateUtils.UpdateInterpProgress(IOUtils.GetAmountOfFiles(Interpolate.current.interpFolder, false, "*.png"), InterpolateUtils.targetFrames); @@ -49,6 +49,12 @@ namespace Flowframes logStr += " - Waiting for encoding to finish..."; Logger.Log(logStr); processTime.Stop(); + while (AvProcess.lastProcess != null && !AvProcess.lastProcess.HasExited) + { + string lastLine = AvProcess.lastOutputFfmpeg.SplitIntoLines().Last(); + Logger.Log(lastLine.Trim(), false, Logger.GetLastLine().Contains("frame")); + await Task.Delay(1000); + } } public static async Task RunDainNcnn(string framesPath, string outPath, int targetFrames, int tilesize)