mirror of
https://github.com/n00mkrad/flowframes.git
synced 2026-02-24 04:00:49 +01:00
More logging cleanup for CLI usage
This commit is contained in:
@@ -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}";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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})";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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()}";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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}";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -45,9 +45,9 @@ namespace Flowframes
|
||||
private static ConcurrentQueue<LogEntry> logQueue = new ConcurrentQueue<LogEntry>();
|
||||
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();
|
||||
}
|
||||
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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<float>(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<Fraction> GetFramerate(string inputFile, bool preferFfmpeg = false)
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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 })
|
||||
{
|
||||
|
||||
@@ -216,7 +216,7 @@ namespace Flowframes.Os
|
||||
|
||||
public static async Task<string> 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();
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user