Skip to content

Commit

Permalink
Add FFmpeg command verbose log (#1248)
Browse files Browse the repository at this point in the history
* Verbose log FFmpeg working dir and args

* Use FFmpeg path when logging
  • Loading branch information
ScrubN committed Nov 10, 2024
1 parent defdc91 commit b105ed8
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
2 changes: 2 additions & 0 deletions TwitchDownloaderCore/ChatRenderer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
13 changes: 13 additions & 0 deletions TwitchDownloaderCore/VideoDownloader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -386,6 +386,8 @@ private async Task<int> 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();

Expand All @@ -401,6 +403,17 @@ private async Task<int> RunFfmpegVideoCopy(string tempFolder, FileInfo outputFil
} while (!process.HasExited || !logQueue.IsEmpty);

return process.ExitCode;

static string CombineArguments(IEnumerable<string> 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)
Expand Down

0 comments on commit b105ed8

Please sign in to comment.