Add ffmpeg version to startup output and log file.
This commit is contained in:
parent
c147a19a0a
commit
181ea8eef1
@ -748,6 +748,61 @@ public class Program
|
|||||||
{
|
{
|
||||||
config.FFmpegPath = config.FFmpegPath.Replace(@"\", @"\\");
|
config.FFmpegPath = config.FFmpegPath.Replace(@"\", @"\\");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Get FFmpeg version
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var processStartInfo = new System.Diagnostics.ProcessStartInfo
|
||||||
|
{
|
||||||
|
FileName = config.FFmpegPath,
|
||||||
|
Arguments = "-version",
|
||||||
|
RedirectStandardOutput = true,
|
||||||
|
RedirectStandardError = true,
|
||||||
|
UseShellExecute = false,
|
||||||
|
CreateNoWindow = true
|
||||||
|
};
|
||||||
|
|
||||||
|
using (var process = System.Diagnostics.Process.Start(processStartInfo))
|
||||||
|
{
|
||||||
|
if (process != null)
|
||||||
|
{
|
||||||
|
string output = await process.StandardOutput.ReadToEndAsync();
|
||||||
|
await process.WaitForExitAsync();
|
||||||
|
|
||||||
|
// Log full output
|
||||||
|
Log.Information("FFmpeg version output:\n{Output}", output);
|
||||||
|
|
||||||
|
// Parse first line for console output
|
||||||
|
string firstLine = output.Split('\n')[0].Trim();
|
||||||
|
if (firstLine.StartsWith("ffmpeg version"))
|
||||||
|
{
|
||||||
|
// Extract version string (text between "ffmpeg version " and " Copyright")
|
||||||
|
int versionStart = "ffmpeg version ".Length;
|
||||||
|
int copyrightIndex = firstLine.IndexOf(" Copyright");
|
||||||
|
if (copyrightIndex > versionStart)
|
||||||
|
{
|
||||||
|
string version = firstLine.Substring(versionStart, copyrightIndex - versionStart);
|
||||||
|
AnsiConsole.Markup($"[green]ffmpeg version detected as {version}[/]\n");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Fallback if Copyright not found
|
||||||
|
string version = firstLine.Substring(versionStart);
|
||||||
|
AnsiConsole.Markup($"[green]ffmpeg version detected as {version}[/]\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
AnsiConsole.Markup($"[yellow]ffmpeg version could not be parsed[/]\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
Log.Warning(ex, "Failed to get FFmpeg version");
|
||||||
|
AnsiConsole.Markup($"[yellow]Could not retrieve ffmpeg version[/]\n");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user