I have a app that is doing some video processing.
I need to analyze the media before processing it.
The ffmpeg utility ffprobe.exe provides all the information I need.
However the code I am using will not return the text that appears when the command is ran in a cmd window :
public static string RunConsoleCommand(string command, string args)
{
var consoleOut = "";
using (var process = new Process())
{
process.StartInfo = new ProcessStartInfo
{
FileName = command,
Arguments = args,
UseShellExecute = false,
CreateNoWindow = true,
RedirectStandardOutput = true
};
process.Start();
consoleOut = process.StandardOutput.ReadToEnd();
process.WaitForExit();
return consoleOut;
}
}
Any Ideas?
The Process class has some events to handle that :
You also have ErrorDataReceived, which works the same way.
I’m using these events in some projects, and it works like a charm. Hope that helps.
EDIT : Fixed the code, you need to attach the handlers before you start the process.