title: How to get output from ffmpeg process in c#
body: <p>In the code I written in WPF, I run some filter in FFmpeg, If I run the command in terminal (PowerShell or cmd prompt) It will give me information line by line what's going on.</p>
  
  <p>I am calling the process from C# code and it's work fine. The problem I have with my code is actually I am not able to get any output from the process I run. </p>
  
  <p>I have tried some answers from StackOverflow for FFmpeg process. I see 2 opportunities in my code. I can either fix it by Timer approach or secondly hook an event to OutputDataReceived.</p>
  
  <p>I tried OutputDataReceived event, My code never got it worked. I tried Timer Approach but still, it's not hitting my code. Please check the code below</p>
  
  <pre><code>        _process = new Process
          {
              StartInfo = new ProcessStartInfo
              {
                  FileName = ffmpeg,
                  Arguments = arguments,
                  UseShellExecute = false,
                  RedirectStandardOutput = true,
                  RedirectStandardError = true,
                  CreateNoWindow = true,
              },
              EnableRaisingEvents = true
          };
  
          _process.OutputDataReceived += Proc_OutputDataReceived;
  
          _process.Exited += (a, b) =&gt;
          {
              System.Threading.Tasks.Task.Run(() =&gt;
              {
                  System.Threading.Tasks.Task.Delay(5000);
                  System.IO.File.Delete(newName);
              });
  
              //System.IO.File.Delete()
          };
  
          _process.Start();
          _timer = new Timer();
          _timer.Interval = 500;
          _timer.Start();
          _timer.Tick += Timer_Tick;
      }
  
  
      private void Timer_Tick(object sender, EventArgs e)
      {
          while (_process.StandardOutput.EndOfStream)
          {
             string line = _process.StandardOutput.ReadLine();
          }
          // Check the process.
  
      }
  </code></pre>