private void ProcessIt(string command, int? timeoutMilliseconds) { using (var ffmpegProcess = new Process()) { ffmpegProcess.StartInfo = new ProcessStartInfo { FileName = ResourceManagement.CommandConfiguration.FFmpegPath, WorkingDirectory = ResourceManagement.CommandConfiguration.TempPath, Arguments = command.Trim(), CreateNoWindow = true, UseShellExecute = false, RedirectStandardError = true, }; Log.Debug($"ffmpeg.exe MonoRuntime={ResourceManagement.IsMonoRuntime()} Args={ffmpegProcess.StartInfo.Arguments}"); var stdErrorReader = StandardErrorAsyncStreamReader.AttachReader(ffmpegProcess); ffmpegProcess.Start(); //workaround for a bug in the mono process when attempting to read async from console output events // - link http://mono.1490590.n4.nabble.com/System-Diagnostic-Process-and-event-handlers-td3246096.html // we will wait a total of 10 seconds for the process to start, if nothing has happened in that time then we will // return a failure for the event. ffmpegProcess.WaitForProcessStart(); stdErrorReader.Listen(); var processStopped = ffmpegProcess.WaitForProcessStop(timeoutMilliseconds); if (!processStopped) { throw new FFmpegTimeoutException(ffmpegProcess.StartInfo.Arguments); } stdErrorReader.Stop(); StdOut = stdErrorReader.ToString(); Log.Debug($"ffmpeg.exe MonoRuntime={ResourceManagement.IsMonoRuntime()} Output={StdOut}."); var exitCode = ffmpegProcess.ExitCode; if (exitCode != 0) { throw new FFmpegProcessingException(exitCode, StdOut); } } }