From b105ed806061079c90235e3ba670a3722348c339 Mon Sep 17 00:00:00 2001 From: Scrub <72096833+ScrubN@users.noreply.github.com> Date: Sat, 9 Nov 2024 21:56:19 -0500 Subject: [PATCH] Add FFmpeg command verbose log (#1248) * Verbose log FFmpeg working dir and args * Use FFmpeg path when logging --- TwitchDownloaderCore/ChatRenderer.cs | 2 ++ TwitchDownloaderCore/VideoDownloader.cs | 13 +++++++++++++ 2 files changed, 15 insertions(+) diff --git a/TwitchDownloaderCore/ChatRenderer.cs b/TwitchDownloaderCore/ChatRenderer.cs index 5241de47..2851ccd3 100644 --- a/TwitchDownloaderCore/ChatRenderer.cs +++ b/TwitchDownloaderCore/ChatRenderer.cs @@ -390,6 +390,8 @@ private FfmpegProcess GetFfmpegProcess(FileInfo fileInfo) } }; + _progress.LogVerbose($"Running \"{renderOptions.FfmpegPath}\" in \"{process.StartInfo.WorkingDirectory}\" with args: {process.StartInfo.Arguments}"); + process.Start(); process.BeginErrorReadLine(); process.BeginOutputReadLine(); diff --git a/TwitchDownloaderCore/VideoDownloader.cs b/TwitchDownloaderCore/VideoDownloader.cs index b32d10f6..b2f74b92 100644 --- a/TwitchDownloaderCore/VideoDownloader.cs +++ b/TwitchDownloaderCore/VideoDownloader.cs @@ -386,6 +386,8 @@ private async Task RunFfmpegVideoCopy(string tempFolder, FileInfo outputFil HandleFfmpegOutput(e.Data, encodingTimeRegex, videoLength); }; + _progress.LogVerbose($"Running \"{downloadOptions.FfmpegPath}\" in \"{process.StartInfo.WorkingDirectory}\" with args: {CombineArguments(process.StartInfo.ArgumentList)}"); + process.Start(); process.BeginErrorReadLine(); @@ -401,6 +403,17 @@ private async Task RunFfmpegVideoCopy(string tempFolder, FileInfo outputFil } while (!process.HasExited || !logQueue.IsEmpty); return process.ExitCode; + + static string CombineArguments(IEnumerable args) + { + return string.Join(' ', args.Select(x => + { + if (!x.StartsWith('"') && !x.StartsWith('\'') && x.Contains(' ')) + return $"\"{x}\""; + + return x; + })); + } } private void HandleFfmpegOutput(string output, Regex encodingTimeRegex, TimeSpan videoLength)