diff --git a/Code/Form1.cs b/Code/Form1.cs index 7b1905c..7b88f65 100644 --- a/Code/Form1.cs +++ b/Code/Form1.cs @@ -229,7 +229,7 @@ namespace Flowframes public void UpdateInputInfo() { string str = $"Size: {(!currInRes.IsEmpty ? $"{currInRes.Width}x{currInRes.Height}" : "Unknown")} - "; - str += $"Rate: {(currInFpsDetected.GetFloat() > 0f ? $"{currInFpsDetected} ({currInFpsDetected.GetFloat()})" : "Unknown")} - "; + str += $"FPS: {(currInFpsDetected.GetFloat() > 0f ? $"{currInFpsDetected} ({currInFpsDetected.GetFloat().ToString("0.000")})" : "Unknown")} - "; str += $"Frames: {(currInFrames > 0 ? $"{currInFrames}" : "Unknown")} - "; str += $"Duration: {(currInDuration > 0 ? FormatUtils.MsToTimestamp(currInDuration) : "Unknown")}"; inputInfo.Text = str; diff --git a/Code/Main/Interpolate.cs b/Code/Main/Interpolate.cs index 30bf055..786aa49 100644 --- a/Code/Main/Interpolate.cs +++ b/Code/Main/Interpolate.cs @@ -149,7 +149,7 @@ namespace Flowframes if(extractedFrames == 1) Cancel("Only a single frame was extracted from your input file!\n\nPossibly your input is an image, not a video?"); else - Cancel($"Frame extraction failed!\nExtracted {extractedFrames} frames.\n\nYour input file might be incompatible."); + Cancel($"Frame extraction failed!\nExtracted {extractedFrames} frames - current.framesFolder exists: {Directory.Exists(current.framesFolder)} - currentInputFrameCount = {currentInputFrameCount} - extractedFrames = {extractedFrames}.\n\nYour input file might be incompatible."); } if (Config.GetInt(Config.Key.dedupMode) == 1) diff --git a/Code/Media/AvOutputHandler.cs b/Code/Media/AvOutputHandler.cs index 79bb060..a751bfb 100644 --- a/Code/Media/AvOutputHandler.cs +++ b/Code/Media/AvOutputHandler.cs @@ -120,7 +120,7 @@ namespace Flowframes.Media static bool HideMessage(string msg) { - string[] hiddenMsgs = new string[] { "can produce invalid output", "pixel format", "provided invalid" }; + string[] hiddenMsgs = new string[] { "can produce invalid output", "pixel format", "provided invalid", "Non-monotonous", "not enough frames to estimate rate", "invalid dropping", "message repeated" }; foreach (string str in hiddenMsgs) if (msg.MatchesWildcard($"*{str}*")) diff --git a/Code/Media/FfmpegCommands.cs b/Code/Media/FfmpegCommands.cs index caaf237..793aeb3 100644 --- a/Code/Media/FfmpegCommands.cs +++ b/Code/Media/FfmpegCommands.cs @@ -170,7 +170,7 @@ namespace Flowframes frames = await ReadFrameCountFfmpegAsync(inputFile); // Try reading frame count with ffmpeg if (frames > 0) return frames; - Logger.Log("Failed to get total frame count of video."); + Logger.Log("Failed to get total frame count of video.", true); return 0; } diff --git a/Code/Media/GetFrameCountCached.cs b/Code/Media/GetFrameCountCached.cs index cba8e0d..144ca06 100644 --- a/Code/Media/GetFrameCountCached.cs +++ b/Code/Media/GetFrameCountCached.cs @@ -9,9 +9,9 @@ namespace Flowframes.Media { class GetFrameCountCached { - public static Dictionary cache = new Dictionary(); + private static Dictionary cache = new Dictionary(); - public static async Task GetFrameCountAsync(string path) + public static async Task GetFrameCountAsync(string path, int retryCount = 3) { Logger.Log($"Getting frame count ({path})", true); @@ -35,8 +35,23 @@ namespace Flowframes.Media else frameCount = await FfmpegCommands.GetFrameCountAsync(path); - Logger.Log($"Adding hash with value {frameCount} to cache.", true); - cache.Add(hash, frameCount); + if(frameCount > 0) + { + Logger.Log($"Adding hash with value {frameCount} to cache.", true); + cache.Add(hash, frameCount); + } + else + { + if (retryCount > 0) + { + Logger.Log($"Got {frameCount} frames, retrying ({retryCount} left)", true); + frameCount = await GetFrameCountAsync(path, retryCount - 1); + } + else + { + Logger.Log($"Failed to get frames and out of retries ({frameCount} frames for {path})", true); + } + } return frameCount; } @@ -58,5 +73,10 @@ namespace Flowframes.Media return 0; } + + public static void Clear () + { + cache.Clear(); + } } } diff --git a/Code/Media/GetMediaResolutionCached.cs b/Code/Media/GetMediaResolutionCached.cs index aa0a3a4..548c1aa 100644 --- a/Code/Media/GetMediaResolutionCached.cs +++ b/Code/Media/GetMediaResolutionCached.cs @@ -9,7 +9,7 @@ namespace Flowframes.Media { class GetMediaResolutionCached { - public static Dictionary cache = new Dictionary(); + private static Dictionary cache = new Dictionary(); public static async Task GetSizeAsync(string path) { @@ -31,8 +31,11 @@ namespace Flowframes.Media Size size; size = await IoUtils.GetVideoOrFramesRes(path); - Logger.Log($"Adding hash with value {size} to cache.", true); - cache.Add(hash, size); + if(size.Width > 0 && size.Height > 0) + { + Logger.Log($"Adding hash with value {size} to cache.", true); + cache.Add(hash, size); + } return size; } @@ -54,5 +57,10 @@ namespace Flowframes.Media return new Size(); } + + public static void Clear() + { + cache.Clear(); + } } } diff --git a/Code/Ui/MainUiFunctions.cs b/Code/Ui/MainUiFunctions.cs index 1f0f4dc..117ffc0 100644 --- a/Code/Ui/MainUiFunctions.cs +++ b/Code/Ui/MainUiFunctions.cs @@ -23,6 +23,9 @@ namespace Flowframes.Ui Program.mainForm.ResetInputInfo(); string path = inputTbox.Text.Trim(); + GetFrameCountCached.Clear(); + GetMediaResolutionCached.Clear(); + if (Config.GetBool(Config.Key.clearLogOnInput)) Logger.ClearLogBox();