I have the method:
public static string StartProcess(string exePathArg, string argumentsArg, int timeToWaitForProcessToExit)
{
string retMessage = "";
using (Process p = new Process())
{
p.StartInfo.FileName = exePathArg;
p.StartInfo.RedirectStandardOutput = true;
p.StartInfo.Arguments = argumentsArg;
p.StartInfo.UseShellExecute = false;
try
{
p.Start();
StreamReader myOutput = p.StandardOutput;
retMessage = "STANDARD OUTPUT: " + myOutput.ReadToEnd();
p.WaitForExit(timeToWaitForProcessToExit);
}
catch (Exception ex)
{
retMessage = "EXCEPTION THROWN: " + ex.ToString();
}
finally
{
try
{
p.Kill();
}
catch { }
}
}
return retMessage;
}
But it doesnt redirect my output to retMessage. Anyone any ideas? I tested the arguments in a bat file and output is definitely output.
Cheers, Pete
My guess (agree with dtb's comment):
AFAIK ffmpeg
uses stdout to pipe out binary data(multimedia, snapshots, etc.) and stderr is used for logging purposes. In your example you use stdout.
So, change you code to:
p.StartInfo.RedirectStandardError = true;
...
string log = p.StandardError.ReadToEnd();
and it should solve your problem.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With