From 7aa0a2f70e84ea8b4359fc1a1edcd01976a26779 Mon Sep 17 00:00:00 2001 From: n00mkrad <61149547+n00mkrad@users.noreply.github.com> Date: Thu, 29 Jan 2026 12:13:08 +0100 Subject: [PATCH] More logging cleanup for CLI usage --- CodeLegacy/Data/Streams/AudioStream.cs | 7 +++++-- CodeLegacy/Data/Streams/Stream.cs | 3 ++- CodeLegacy/Data/Streams/SubtitleStream.cs | 3 +-- CodeLegacy/Data/Streams/VideoStream.cs | 2 +- CodeLegacy/Forms/Main/Form1.cs | 3 ++- CodeLegacy/IO/Logger.cs | 4 ++-- CodeLegacy/Media/AvProcess.cs | 4 ++-- CodeLegacy/Media/FfmpegCommands.cs | 14 +++++++++----- CodeLegacy/Media/FfmpegUtils.cs | 6 +++--- CodeLegacy/Media/GetMediaResolutionCached.cs | 2 +- CodeLegacy/Media/GetVideoInfo.cs | 2 +- CodeLegacy/NUtilsTemp.cs | 2 +- CodeLegacy/Os/OsUtils.cs | 2 +- CodeLegacy/Ui/MainUiFunctions.cs | 2 +- 14 files changed, 32 insertions(+), 24 deletions(-) diff --git a/CodeLegacy/Data/Streams/AudioStream.cs b/CodeLegacy/Data/Streams/AudioStream.cs index 3042954..84c32d1 100644 --- a/CodeLegacy/Data/Streams/AudioStream.cs +++ b/CodeLegacy/Data/Streams/AudioStream.cs @@ -22,8 +22,11 @@ public override string ToString() { - string title = string.IsNullOrWhiteSpace(Title.Trim()) ? "None" : Title; - return $"{base.ToString()} - Language: {Language} - Title: {title} - Kbps: {Kbits} - SampleRate: {SampleRate} - Channels: {Channels} - Layout: {Layout}"; + string title = string.IsNullOrWhiteSpace(Title) ? " - Untitled" : $" - '{Title}'"; + string bitrate = Kbits > 0 ? $" - Kbps: {Kbits}" : ""; + string sampleRate = SampleRate > 0 ? $" - Rate: {(SampleRate / 1000).ToString("0.0#")} kHz" : ""; + string layout = Layout.IsNotEmpty() ? $" [{Layout.Replace("(", " ").Replace(")", " ").Trim()}]" : ""; + return $"{base.ToString()} - Language: {LanguageFmt}{title}{bitrate}{sampleRate} - Channels: {Channels}{layout}"; } } } diff --git a/CodeLegacy/Data/Streams/Stream.cs b/CodeLegacy/Data/Streams/Stream.cs index 4937456..05abd33 100644 --- a/CodeLegacy/Data/Streams/Stream.cs +++ b/CodeLegacy/Data/Streams/Stream.cs @@ -9,11 +9,12 @@ public string Codec = ""; public string CodecLong = ""; public string Language = ""; + public string LanguageFmt => Language.Trim().IsEmpty() ? "N/A" : Language.Replace("und", "N/A").Upper(); public string Title = ""; public override string ToString() { - return $"Stream #{Index.ToString().PadLeft(2, '0')}{(IsDefault ? "*" : "")} - {Codec} {Type}"; + return $"Stream #{Index.ToString().PadLeft(2, '0')}{(IsDefault ? "*" : "")} {Type} ({Codec})"; } } } diff --git a/CodeLegacy/Data/Streams/SubtitleStream.cs b/CodeLegacy/Data/Streams/SubtitleStream.cs index 245911e..3162021 100644 --- a/CodeLegacy/Data/Streams/SubtitleStream.cs +++ b/CodeLegacy/Data/Streams/SubtitleStream.cs @@ -16,9 +16,8 @@ public override string ToString() { - string lang = string.IsNullOrWhiteSpace(Language.Trim()) ? "?" : Language; string ttl = string.IsNullOrWhiteSpace(Title.Trim()) ? "None" : Title; - return $"{base.ToString()} - Language: {lang} - Title: {ttl} - Bitmap-based: {Bitmap.ToString().ToTitleCase()}"; + return $"{base.ToString()} - Language: {LanguageFmt} - Title: {ttl} - Bitmap-based: {Bitmap.ToString().ToTitleCase()}"; } } } diff --git a/CodeLegacy/Data/Streams/VideoStream.cs b/CodeLegacy/Data/Streams/VideoStream.cs index 7d97e9e..869d598 100644 --- a/CodeLegacy/Data/Streams/VideoStream.cs +++ b/CodeLegacy/Data/Streams/VideoStream.cs @@ -36,7 +36,7 @@ namespace Flowframes.Data.Streams public override string ToString() { - return $"{base.ToString()} - Language: {Language} - Color Format: {PixelFormat} - Size: {Resolution.Width}x{Resolution.Height} - FPS: {Rate}"; + return $"{base.ToString()} - Language: {LanguageFmt} - Pixel Format: {PixelFormat} - Size: {Resolution.Width}x{Resolution.Height} - FPS: {Rate}"; } } } diff --git a/CodeLegacy/Forms/Main/Form1.cs b/CodeLegacy/Forms/Main/Form1.cs index 443b565..1be2bf1 100644 --- a/CodeLegacy/Forms/Main/Form1.cs +++ b/CodeLegacy/Forms/Main/Form1.cs @@ -595,7 +595,8 @@ namespace Flowframes.Forms.Main public void ValidateFactor() { - interpFactorCombox.Text = $"x{MainUiFunctions.ValidateInterpFactor(interpFactorCombox.GetFloat())}"; + float validFactor = MainUiFunctions.ValidateInterpFactor(interpFactorCombox.GetFloat()); + interpFactorCombox.Text = $"x{validFactor}"; } public void SetWorking(bool state, bool allowCancel = true) diff --git a/CodeLegacy/IO/Logger.cs b/CodeLegacy/IO/Logger.cs index add03b8..ac5bb77 100644 --- a/CodeLegacy/IO/Logger.cs +++ b/CodeLegacy/IO/Logger.cs @@ -45,9 +45,9 @@ namespace Flowframes private static ConcurrentQueue logQueue = new ConcurrentQueue(); private static readonly string _logPath = Paths.GetLogPath(); - public static void Log(string msg, bool hidden = false, bool replaceLastLine = false, string filename = "", bool toConsole = true) + public static void Log(object msg, bool hidden = false, bool replaceLastLine = false, string filename = "", bool toConsole = true) { - logQueue.Enqueue(new LogEntry(msg, hidden, replaceLastLine, filename, toConsole)); + logQueue.Enqueue(new LogEntry(msg.ToString(), hidden, replaceLastLine, filename, toConsole)); ShowNext(); } diff --git a/CodeLegacy/Media/AvProcess.cs b/CodeLegacy/Media/AvProcess.cs index 426381d..d4b683a 100644 --- a/CodeLegacy/Media/AvProcess.cs +++ b/CodeLegacy/Media/AvProcess.cs @@ -143,7 +143,7 @@ namespace Flowframes ffprobe.StartInfo.Arguments = $"/C cd /D {GetAvDir().Wrap()} & ffprobe {args}"; if (settings.LoggingMode != LogMode.Hidden) Logger.Log("Running FFprobe...", false); - Logger.Log($"ffprobe {args}", true, false, "ffmpeg"); + Logger.Log($"ffprobe {args}", true, false, "ffmpeg", toConsole: Cli.Verbose); if (!asyncOutput) return await Task.Run(() => OsUtils.GetProcStdOut(ffprobe)); @@ -166,7 +166,7 @@ namespace Flowframes { Process ffprobe = OsUtils.NewProcess(true); ffprobe.StartInfo.Arguments = $"/C cd /D {GetAvDir().Wrap()} & ffprobe.exe {args}"; - Logger.Log($"ffprobe {args}", true, false, "ffmpeg"); + Logger.Log($"ffprobe {args}", true, false, "ffmpeg", toConsole: Cli.Verbose); ffprobe.Start(); ffprobe.WaitForExit(); string output = ffprobe.StandardOutput.ReadToEnd(); diff --git a/CodeLegacy/Media/FfmpegCommands.cs b/CodeLegacy/Media/FfmpegCommands.cs index 805a113..181d092 100644 --- a/CodeLegacy/Media/FfmpegCommands.cs +++ b/CodeLegacy/Media/FfmpegCommands.cs @@ -174,7 +174,7 @@ namespace Flowframes if (mediaFile.InputTimestamps.Any()) return; - Logger.Log($"Checking frame timing...", true, false, "ffmpeg"); + Logger.Log($"[VFR Check] Checking frame timing...", true, false, "ffmpeg"); if (outputLinesPackets == null) { @@ -222,30 +222,34 @@ namespace Flowframes float avgDuration = timestampDurations.Average(); float maxDeviationMs = (timestampDurations.Max() - timestampDurations.Min()) * 1000f; float maxDeviationPercent = ((timestampDurations.Max() / timestampDurations.Min()) * 100f) - 100; + string maxDevPercentStr = maxDeviationPercent.ToString("0.##") + "%"; + string maxDevMsStr = maxDeviationMs.ToString("0.###") + " ms"; // float maxDeviationMsResampled = (timestampDurationsRes.Max() - timestampDurationsRes.Min()) * 1000f; - Logger.Log($"[VFR Check] Timestamp durations - Min: {timestampDurations.Min() * 1000f} ms - Max: {timestampDurations.Max() * 1000f} ms - Avg: {avgDuration * 1000f} - Biggest deviation: {maxDeviationMs.ToString("0.##")} ms", hidden: true); + Logger.Log($"[VFR Check] Timestamp durations - Min: {timestampDurations.Min() * 1000f} ms - Max: {timestampDurations.Max() * 1000f} ms - Avg: {avgDuration * 1000f} - Largest deviation: {maxDeviationMs.ToString("0.##")} ms", hidden: true); // Logger.Log($"Resampled - Min ts duration: {timestampDurationsRes.Min() * 1000f} ms - Max ts duration: {timestampDurationsRes.Max() * 1000f} ms - Biggest deviation: {maxDeviationMsResampled.ToString("0.##")} ms", hidden: true); mediaFile.InputTimestampDurations = new List(timestampDurations); if (Config.GetInt(Config.Key.vfrHandling) == 1) { - Logger.Log($"Ignoring VFR deviation threshold of {maxDeviationPercent.ToString("0.##")}%, force-enabling VFR mode due to settings"); + Logger.Log($"Ignoring VFR deviation threshold of {maxDevPercentStr}, force-enabling VFR mode due to settings"); mediaFile.IsVfr = true; return; } else if (Config.GetInt(Config.Key.vfrHandling) == 2) { - Logger.Log($"Ignoring VFR deviation threshold of {maxDeviationPercent.ToString("0.##")}%, force-disabling VFR mode due to settings"); + Logger.Log($"Ignoring VFR deviation threshold of {maxDevPercentStr}, force-disabling VFR mode due to settings"); mediaFile.IsVfr = false; return; } if (maxDeviationPercent > 20f) { - Logger.Log($"[VFR Check] Max timestamp deviation is {maxDeviationPercent.ToString("0.##")}% or {maxDeviationMs} ms - Assuming VFR input!", hidden: true); + Logger.Log($"[VFR Check] Max timestamp deviation is {maxDevPercentStr} ({maxDevMsStr}) - Assuming VFR input!", hidden: true); mediaFile.IsVfr = true; } + + Logger.Log($"[VFR Check] Max timestamp deviation is only {maxDevPercentStr} ({maxDevMsStr}) - Assuming CFR input.", hidden: true); } public static async Task GetFramerate(string inputFile, bool preferFfmpeg = false) diff --git a/CodeLegacy/Media/FfmpegUtils.cs b/CodeLegacy/Media/FfmpegUtils.cs index 628a8ee..9f50fa8 100644 --- a/CodeLegacy/Media/FfmpegUtils.cs +++ b/CodeLegacy/Media/FfmpegUtils.cs @@ -68,7 +68,7 @@ namespace Flowframes.Media int frameCount = countFrames ? await GetFrameCountCached.GetFrameCountAsync(path) : 0; FpsInfo fps = await GetFps(path, str, idx, (Fraction)defaultFps, frameCount, allowFpsOverride: !mediaFile.IsVfr); VideoStream vStream = new VideoStream(lang, title, codec, codecLong, pixFmt, kbits, res, sar, dar, fps, frameCount) { Index = idx, IsDefault = def }; - Logger.Log($"Video stream: {vStream}", true); + Logger.Log(vStream, true); streams.Add(vStream); continue; } @@ -88,7 +88,7 @@ namespace Flowframes.Media AudioStream aStream = new AudioStream(lang, title, codec, codecLong, kbits, sampleRate, channels, layout); aStream.Index = idx; aStream.IsDefault = def; - Logger.Log($"Audio stream: {aStream}", true); + Logger.Log(aStream, true); streams.Add(aStream); continue; } @@ -103,7 +103,7 @@ namespace Flowframes.Media SubtitleStream sStream = new SubtitleStream(lang, title, codec, codecLong, bitmap); sStream.Index = idx; sStream.IsDefault = def; - Logger.Log($"Subtitle stream: {sStream}", true); + // Logger.Log(sStream", true); streams.Add(sStream); continue; } diff --git a/CodeLegacy/Media/GetMediaResolutionCached.cs b/CodeLegacy/Media/GetMediaResolutionCached.cs index 8e7687e..fa07099 100644 --- a/CodeLegacy/Media/GetMediaResolutionCached.cs +++ b/CodeLegacy/Media/GetMediaResolutionCached.cs @@ -19,7 +19,7 @@ namespace Flowframes.Media if (filesize > 0 && cache.ContainsKey(hash)) { Size cachedVal = cache[hash]; - Logger.Log($"Resolution of '{Path.GetFileName(path)}': {cachedVal.Width}x{cachedVal.Height} [Cached]", true); + Logger.Log($"Resolution of '{Path.GetFileName(path)}': {cachedVal.Width}x{cachedVal.Height} [Cached]", true, toConsole: Cli.Verbose); return cachedVal; } diff --git a/CodeLegacy/Media/GetVideoInfo.cs b/CodeLegacy/Media/GetVideoInfo.cs index c7e9e0b..4cb36a8 100644 --- a/CodeLegacy/Media/GetVideoInfo.cs +++ b/CodeLegacy/Media/GetVideoInfo.cs @@ -93,7 +93,7 @@ namespace Flowframes.Media if (!noCache && filesize > 0 && cmdCache.ContainsKey(hash)) return cmdCache[hash]; - Logger.Log($"GetVideoInfo: '{path}' (not cached)", true, false, "ffmpeg"); + Logger.Log($"GetVideoInfo: '{path}' (not cached)", true, false, "ffmpeg", toConsole: Cli.Verbose); string output = await OsUtils.GetOutputAsync(process); cmdCache.Add(hash, output); return output; diff --git a/CodeLegacy/NUtilsTemp.cs b/CodeLegacy/NUtilsTemp.cs index efd1d7a..c3c1d86 100644 --- a/CodeLegacy/NUtilsTemp.cs +++ b/CodeLegacy/NUtilsTemp.cs @@ -76,7 +76,7 @@ namespace Flowframes CreateNoWindow = true, }; - Logger.Log($"{startInfo.FileName} {startInfo.Arguments}", hidden: true); + Logger.Log($"{startInfo.FileName} {startInfo.Arguments}", hidden: true, toConsole: Cli.Verbose); using (Process process = new Process { StartInfo = startInfo }) { diff --git a/CodeLegacy/Os/OsUtils.cs b/CodeLegacy/Os/OsUtils.cs index 20a68ed..9e76c7a 100644 --- a/CodeLegacy/Os/OsUtils.cs +++ b/CodeLegacy/Os/OsUtils.cs @@ -216,7 +216,7 @@ namespace Flowframes.Os public static async Task GetOutputAsync(Process process, bool onlyLastLine = false) { - Logger.Log($"Getting output for {process.StartInfo.FileName} {process.StartInfo.Arguments}", true); + Logger.Log($"Getting output for {process.StartInfo.FileName} {process.StartInfo.Arguments}", true, toConsole: Cli.Verbose); NmkdStopwatch sw = new NmkdStopwatch(); Stopwatch timeSinceLastOutput = new Stopwatch(); diff --git a/CodeLegacy/Ui/MainUiFunctions.cs b/CodeLegacy/Ui/MainUiFunctions.cs index 603c9d1..1881efc 100644 --- a/CodeLegacy/Ui/MainUiFunctions.cs +++ b/CodeLegacy/Ui/MainUiFunctions.cs @@ -50,7 +50,7 @@ namespace Flowframes.Ui string fpsStr = fps.Float > 0 ? FormatUtils.Fraction(fps) : "Not Found"; Program.mainForm.currInFpsDetected = fps; fpsInTbox.Text = fps.GetString(); - Logger.Log($"Video FPS: {fpsStr} - Total Number Of Frames: {Interpolate.currentMediaFile.FrameCount}{(Interpolate.currentMediaFile.VideoExtraData.IsHdr ? " - HDR" : "")}", false, true); + Logger.Log($"Video FPS: {fpsStr} - Number of Frames: {Interpolate.currentMediaFile.FrameCount}{(Interpolate.currentMediaFile.VideoExtraData.IsHdr ? " - HDR" : "")}", false, true); Program.mainForm.GetInputFpsTextbox().ReadOnly = (fps.Float > 0 && !Config.GetBool("allowCustomInputRate", false)); Program.mainForm.currInFps = fps; Program.mainForm.currInFrames = Interpolate.currentMediaFile.FrameCount;