title: Retrieving information from ffmpeg shell_exec command
body: <p>i am doing the following</p>
  
  <pre><code>$output = shell_exec('/usr/local/bin/ffmpeg -i intro.mp3 2&gt;&amp;1'); 
  echo "&lt;pre&gt;$output&lt;/pre&gt;";
  </code></pre>
  
  <p>This outputs</p>
  
  <pre><code>ffmpeg version 0.8.5, Copyright (c) 2000-2011 the FFmpeg developers
    built on Aug 20 2012 09:28:43 with clang 3.1 (tags/Apple/clang-318.0.61)
    configuration: --enable-nonfree --enable-gpl --enable-version3 --enable-postproc --enable-swscale --enable-avfilter --enable-libmp3lame --enable-libvorbis --enable-libtheora --enable-libfaac --enable-libxvid --enable-libx264 --enable-libvpx --enable-hardcoded-tables --enable-shared --enable-pthreads --disable-indevs --cc=clang
    libavutil    51.  9. 1 / 51.  9. 1
    libavcodec   53.  7. 0 / 53.  7. 0
    libavformat  53.  4. 0 / 53.  4. 0
    libavdevice  53.  1. 1 / 53.  1. 1
    libavfilter   2. 23. 0 /  2. 23. 0
    libswscale    2.  0. 0 /  2.  0. 0
    libpostproc  51.  2. 0 / 51.  2. 0
  [mp3 @ 0x7f9481807c00] max_analyze_duration 5000000 reached at 5015510
  Input #0, mp3, from 'intro.mp3':
    Metadata:
      album           : Frank 
      artist          : Amy Winehouse
      genre           : R&amp;B
      title           : [Intro] Stronger Than Me
      track           : 01
      date            : 2008
    Duration: 00:03:54.71, start: 0.000000, bitrate: 230 kb/s
      Stream #0.0: Audio: mp3, 44100 Hz, stereo, s16, 160 kb/s
  At least one output file must be specified
  </code></pre>
  
  <p>i want to get the information to insert into a database album,artist,genre,title etc</p>
  
  <p>But all seperately</p>
  
  <p>i can get them by doing the following</p>
  
  <pre><code>$output = shell_exec('/usr/local/bin/ffmpeg -i intro.mp3 2&gt;&amp;1'); 
  
  $edit = explode('  ', $output);
  $edit = implode("@", $edit);
  $edit = explode(':', $output);
  echo "&lt;pre&gt;";
  print_r($edit);
  echo "&lt;/pre&gt;";
  </code></pre>
  
  <p>then running </p>
  
  <pre><code>&lt;?php echo $edit[9]; ?&gt;
  </code></pre>
  
  <p>etc</p>
  
  <p>but this seems like a really bad way and annoying way to get values and sometimes the output is slightly different which messes with the outputs.</p>
  
  <p>Whats the best way to do this or am i stuck doing this?</p>