title: Capture FFMPEG output
body: <p>I need to read the output from ffmpeg in order to even try the solution to <a href="https://stackoverflow.com/questions/1106955/php-and-ffmpeg-performing-intelligent-video-conversion">my question from yesterday</a>.  This is a separate issue from my problem there, so I made a new question.</p>
  
  <p>How the heck do I get the output from an <code>ffmpeg -i</code> command in PHP?</p>
  
  <p>This is what I've been trying:</p>
  
  <pre><code>&lt;?PHP
      error_reporting(E_ALL);
      $src = "/var/videos/video1.wmv";
      $command = "/usr/bin/ffmpeg -i " . $src;
      echo "&lt;B&gt;",$command,"&lt;/B&gt;&lt;br/&gt;";
      $command = escapeshellcmd($command);
  
      echo "backtick:&lt;br/&gt;&lt;pre&gt;";
      `$command`;
  
      echo "&lt;/pre&gt;&lt;br/&gt;system:&lt;br/&gt;&lt;pre&gt;";
      echo system($command);
  
      echo "&lt;/pre&gt;&lt;br/&gt;shell_exec:&lt;br/&gt;&lt;pre&gt;";
      echo shell_exec($command);
  
      echo "&lt;/pre&gt;&lt;br/&gt;passthru:&lt;br/&gt;&lt;pre&gt;";
      passthru($command);
  
      echo "&lt;/pre&gt;&lt;br/&gt;exec:&lt;br/&gt;&lt;pre&gt;";
      $output = array();
      exec($command,$output,$status);
      foreach($output AS $o)
      {
              echo $o , "&lt;br/&gt;";
      }
      echo "&lt;/pre&gt;&lt;br/&gt;popen:&lt;br/&gt;&lt;pre&gt;";
      $handle = popen($command,'r');
      echo fread($handle,1048576);
      pclose($handle);
      echo "&lt;/pre&gt;&lt;br/&gt;";
  ?&gt;
  </code></pre>
  
  <p>This is my output:</p>
  
  <pre><code>&lt;B&gt;/usr/bin/ffmpeg -i /var/videos/video1.wmv&lt;/B&gt;&lt;br/&gt;
  backtick:&lt;br/&gt;
      &lt;pre&gt;&lt;/pre&gt;&lt;br/&gt;
  system:&lt;br/&gt;
      &lt;pre&gt;&lt;/pre&gt;&lt;br/&gt;
  shell_exec:&lt;br/&gt;
      &lt;pre&gt;&lt;/pre&gt;&lt;br/&gt;
  passthru:&lt;br/&gt;
      &lt;pre&gt;&lt;/pre&gt;&lt;br/&gt;
  exec:&lt;br/&gt;
      &lt;pre&gt;&lt;/pre&gt;&lt;br/&gt;
  popen:&lt;br/&gt;
      &lt;pre&gt;&lt;/pre&gt;&lt;br/&gt;
  </code></pre>
  
  <p>I don't get it.  <code>safe_mode</code> is off.  There's nothing in <code>disable_functions</code>.  The directory is <em>owned</em> by <code>www-data</code> (the apache user on my Ubuntu system).  I get a valid status back from <code>exec()</code> and <code>system()</code> and running the same command from the command line give me tons of output.  I feel like I must be missing something obvious but I have no idea what it is.</p>