From 7d2e652dc5e011ebc0d1743d2744333eda86f2e4 Mon Sep 17 00:00:00 2001 From: = <=> Date: Mon, 15 Dec 2025 12:39:56 -0500 Subject: [PATCH] Adding ffmpeg debug reporting config --- OF DL/Entities/Config.cs | 3 +++ OF DL/Entities/IDownloadConfig.cs | 3 +++ OF DL/Helpers/DownloadHelper.cs | 13 +++++++++---- 3 files changed, 15 insertions(+), 4 deletions(-) diff --git a/OF DL/Entities/Config.cs b/OF DL/Entities/Config.cs index a7f6699..bf92880 100644 --- a/OF DL/Entities/Config.cs +++ b/OF DL/Entities/Config.cs @@ -61,6 +61,9 @@ namespace OF_DL.Entities public int ApiRateLimitWindowSeconds { get; set; } = 10; public int MaxLogBodyLength { get; set; } = 2000; public bool EnableJsonResponseBodyRawLogs { get; set; } = false; + [ToggleableConfig] + public bool EnableFfmpegReport { get; set; } = true; + public string FfmpegReportPath { get; set; } = Path.Combine("logs", "diagnostics", "ffmpeg"); // Indicates if you want to download only on specific dates. [ToggleableConfig] diff --git a/OF DL/Entities/IDownloadConfig.cs b/OF DL/Entities/IDownloadConfig.cs index c8bc619..701f634 100644 --- a/OF DL/Entities/IDownloadConfig.cs +++ b/OF DL/Entities/IDownloadConfig.cs @@ -57,6 +57,9 @@ namespace OF_DL.Entities int MaxLogBodyLength { get; set; } bool EnableJsonResponseBodyRawLogs { get; set; } + + bool EnableFfmpegReport { get; set; } + string FfmpegReportPath { get; set; } } } diff --git a/OF DL/Helpers/DownloadHelper.cs b/OF DL/Helpers/DownloadHelper.cs index 77460bf..186bb17 100644 --- a/OF DL/Helpers/DownloadHelper.cs +++ b/OF DL/Helpers/DownloadHelper.cs @@ -632,8 +632,11 @@ public class DownloadHelper : IDownloadHelper // Configure ffmpeg log level and optional report file location bool ffmpegDebugLogging = Log.IsEnabled(Serilog.Events.LogEventLevel.Debug); + bool enableReport = downloadConfig.EnableFfmpegReport; - string logLevelArgs = ffmpegDebugLogging || downloadConfig.LoggingLevel is LoggingLevel.Verbose or LoggingLevel.Debug + bool includeReport = enableReport && (ffmpegDebugLogging || downloadConfig.LoggingLevel is LoggingLevel.Verbose or LoggingLevel.Debug); + + string logLevelArgs = includeReport ? "-loglevel debug -report" : downloadConfig.LoggingLevel switch { @@ -644,10 +647,12 @@ public class DownloadHelper : IDownloadHelper _ => string.Empty }; - if (logLevelArgs.Contains("-report", StringComparison.OrdinalIgnoreCase)) + if (includeReport) { - // Direct ffmpeg report files into the same logs directory Serilog uses (relative to current working directory) - string logDir = Path.GetFullPath(Path.Combine(Environment.CurrentDirectory, "logs")); + string reportDir = string.IsNullOrWhiteSpace(downloadConfig.FfmpegReportPath) + ? Path.Combine("logs", "diagnostics", "ffmpeg") + : downloadConfig.FfmpegReportPath; + string logDir = Path.GetFullPath(reportDir); Directory.CreateDirectory(logDir); string ffReportPath = Path.Combine(logDir, "ffmpeg-%p-%t.log"); // ffmpeg will replace %p/%t Environment.SetEnvironmentVariable("FFREPORT", $"file={ffReportPath}:level=32");