### Eclipse Workspace Patch 1.0
#P ffmpeg_wrapper
Index: ffmpeg_wrapper.module
===================================================================
RCS file: /cvs/drupal/contributions/modules/ffmpeg_wrapper/ffmpeg_wrapper.module,v
retrieving revision 1.1.2.20.2.28
diff -u -r1.1.2.20.2.28 ffmpeg_wrapper.module
--- ffmpeg_wrapper.module	27 Oct 2009 11:35:14 -0000	1.1.2.20.2.28
+++ ffmpeg_wrapper.module	2 Nov 2009 10:36:59 -0000
@@ -332,10 +332,12 @@
  *
  * @param $file
  *   A full system filepath.
+ * @param $audio_only
+ *   TRUE if we are only interested in whether ffmpeg can decode the audio track.
  * @return
  *   TRUE if file is in the list of decodeable files.
  */
-function ffmpeg_wrapper_can_decode($path) {
+function ffmpeg_wrapper_can_decode($path, $audio_only = FALSE) {
   // get the kind of files
   $file_types = ffmpeg_wrapper_get_codecs('decode');
 
@@ -349,6 +351,18 @@
       return true;
     }
   }
+  
+  if ($audio_only) {
+    // is the file an audio-only file which can be decoded?
+    // some files have multiple formats attached to them
+    foreach(explode(',', $file_data['audio']['codec']) as $type) {
+      // is this type in the array of items that we can decode?
+      if (in_array($type, $file_types)) {
+        return true;
+      }
+    }
+  }
+  
   return false;
 }
 
@@ -692,15 +706,17 @@
     // get audio settings
     // format is: codec, sample rate, stereo/mono, bitrate
     $pattern = "/Audio: (.*), ([0-9]*) Hz, (stereo|mono)/";
-    preg_match($pattern, $output, $matches);
-    $file['audio']['codec'] = !empty($matches[1]) ? $matches[1] : 'na';
-    $file['audio']['ar'] = !empty($matches[2]) ? $matches[2] : 'na';
-    $file['audio']['ac'] = (!empty($matches[3]) && $matches[3] == 'stereo') ? 2 : 1;
+    if (preg_match($pattern, $output, $matches)) {
+      $file['audio']['codec'] = !empty($matches[1]) ? $matches[1] : 'na';
+      $file['audio']['ar'] = !empty($matches[2]) ? $matches[2] : 'na';
+      $file['audio']['ac'] = (!empty($matches[3]) && $matches[3] == 'stereo') ? 2 : 1;
+    }
 
     // take the last match and extract the bit rate if present
     $pattern = "/Audio: .* (.*) kb\/s/";
-    preg_match($pattern, $output, $matches);
-    $file['audio']['ab'] = !empty($matches[1]) ? $matches[1] : 'na';
+    if (preg_match($pattern, $output, $matches)) {
+      $file['audio']['ab'] = !empty($matches[1]) ? $matches[1] : 'na';
+    }
 
     // VIDEO ----------------------------------------
     // The formating of video can be difficult. We use 3 different
@@ -776,7 +792,9 @@
 
     // Determine source file's dimensions and proportions.
     $info = ffmpeg_wrapper_file_data($file);
-    if ($info) {
+    // check whether the file is a video file
+    
+    if ($info && !empty($info['video'])) {
       list($orig_x, $orig_y) = explode('x', $info['video']['s']);
       $orig_q = $orig_x / $orig_y;
 
@@ -1056,7 +1074,7 @@
 
   $form['ffmpeg_wrapper'] = array(
     '#type' => 'fieldset',
-    '#title' => t("FFmpeg video conversion settings"),
+    '#title' => t("FFmpeg audio/video conversion settings"),
     '#collapsed' => false,
   );
 
@@ -1069,6 +1087,13 @@
     '#description' => t('Select the output format. Note, some formats may require setting audio or video codecs.'),
   );
 
+  $form['ffmpeg_wrapper']['ffmpeg_audio_only'] = array(
+    '#type' => 'checkbox',
+    '#title' => t('Audio-only preset'),
+    '#default_value' => $configuration['ffmpeg_audio_only'],
+    '#description' => t('Choose this if the output format is an audio-only format without video.'),
+  );
+  
   // ---------------------------------------------
   // Audio options
   $form['ffmpeg_wrapper']['audio'] = array(
