Index: ffmpeg_wrapper/ffmpeg_wrapper.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/ffmpeg_wrapper/ffmpeg_wrapper.module,v
retrieving revision 1.1.2.15
diff -u -r1.1.2.15 ffmpeg_wrapper.module
--- ffmpeg_wrapper/ffmpeg_wrapper.module	3 Sep 2008 14:28:33 -0000	1.1.2.15
+++ ffmpeg_wrapper/ffmpeg_wrapper.module	15 Sep 2008 23:10:41 -0000
@@ -151,7 +151,7 @@
  * @param string $path overrides the system settings
  * @return output of the command
  */
-function ffmpeg_wrapper_run_command($options, $error_check = true, $path) {
+function ffmpeg_wrapper_run_command($options, $error_check = true, $path = '') {
   if (! $path) {
     $path = variable_get('ffmpeg_wrapper_path', '/usr/bin/ffmpeg');
   }
@@ -184,7 +184,7 @@
  * @param string $path
  * @return array
  */
-function ffmpeg_wrapper_vhook_list($path) {
+function ffmpeg_wrapper_vhook_list($path = '') {
   static $files;
   
   // if we have a list already
@@ -273,41 +273,45 @@
     // name
     $pattern ='/[ ]*([D ])([E ])([ VA])([S ])([ D])([ T])[ ]*([a-zA-Z0-9_,]*)[ ]*([a-zA-Z0-9,_ ]*)/';
     preg_match($pattern, $codec, $matches);
-
-    // codec names
-    $a_format['name'] = $matches[7];
-    
-    // get the codec type
-    if ($matches[3] == 'A') {
-      $a_format['type'] = t('audio');
-      $encode_formats[] = $a_format['name'];
-    }
-    else {
-      $a_format['type'] = t('video');
-    }
     
-    // get the decode value
-    if ($matches[1] == 'D') {
-      $a_format['decode'] = t('yes');
-      $decode_formats[] = $a_format['name'];
-    }
-    else {
-      $a_format['decode'] = t('no');       
-    }
-   
-    // get the encode value
-    if ($matches[2] == 'E') {
-      $a_format['encode'] = t('yes');
-      $encode_formats[] = $a_format['name'];
-    }
-    else {
-      $a_format['encode'] = t('no');          
-    }
-   
-    if ($a_format['name']) {     
-      $rows[] = $a_format;
+    if (!empty($matches)) {
+
+      // codec names
+      $a_format['name'] = $matches[7];
+      
+      // get the codec type
+      if ($matches[3] == 'A') {
+        $a_format['type'] = t('audio');
+        $encode_formats[] = $a_format['name'];
+      }
+      else {
+        $a_format['type'] = t('video');
+      }
+      
+      // get the decode value
+      if ($matches[1] == 'D') {
+        $a_format['decode'] = t('yes');
+        $decode_formats[] = $a_format['name'];
+      }
+      else {
+        $a_format['decode'] = t('no');       
+      }
+     
+      // get the encode value
+      if ($matches[2] == 'E') {
+        $a_format['encode'] = t('yes');
+        $encode_formats[] = $a_format['name'];
+      }
+      else {
+        $a_format['encode'] = t('no');          
+      }
+     
+      if ($a_format['name']) {     
+        $rows[] = $a_format;
+      }
+      
     }
-    $a_format = null;    
+    $a_format = null;
   }  
   
   switch ($ret) {
@@ -423,30 +427,31 @@
       $pattern ='/[ ]*([D ])([E ])[ ]*([a-zA-Z0-9_,]*)[ ]*([a-zA-Z0-9,_ ]*)/';
       preg_match($pattern, $format, $matches);
       
-      $a_format['type'] = $matches[3];
-      $a_format['name'] = $matches[4];
-        
-      if ($matches[1] == 'D') {
-        $a_format['decode'] = t('yes');
-        $decode_formats[] = $a_format['type'];
-      }
-      else {
-        $a_format['decode'] = t('no');       
-      }
-       
-      if ($matches[2] == 'E') {
-        $a_format['encode'] = t('yes');
-        $encode_formats[] = $a_format['type'];
-      }
-      else {
-        $a_format['encode'] = t('no');          
+      if (!empty($matches)) {
+        $a_format['type'] = $matches[3];
+        $a_format['name'] = $matches[4];
+          
+        if ($matches[1] == 'D') {
+          $a_format['decode'] = t('yes');
+          $decode_formats[] = $a_format['type'];
+        }
+        else {
+          $a_format['decode'] = t('no');       
+        }
+         
+        if ($matches[2] == 'E') {
+          $a_format['encode'] = t('yes');
+          $encode_formats[] = $a_format['type'];
+        }
+        else {
+          $a_format['encode'] = t('no');          
+        }
+         
+        $a_format['description'] = $matches[4];
+        if ($a_format['description']) {
+          $rows[] = $a_format;
+        }       
       }
-       
-      $a_format['description'] = $matches[4];
-      if ($a_format['description']) {
-        $rows[] = $a_format;
-      }       
-      
     }  
   }
 
@@ -562,7 +567,7 @@
   // check for error conditions    
   foreach ($errors as $error) {
   	preg_match($error, $output, $matches);
-    if ($matches[0]) {
+    if (!empty($matches[0])) {
       ffmpeg_wrapper_error_log($command, $matches[0], $watchdog);
       return false;
     }
@@ -625,7 +630,7 @@
 	// we don't have a configuration setting, load up the defaults
 	// for any thing that we don't have data for. First check 
 	// and see if we have a cache
-	//$cache = cache_get('ffmpeg_wrapper_default_output', 'cache');
+	$cache = cache_get('ffmpeg_wrapper_default_output', 'cache');
 	if (unserialize($cache->data)) {
 	  return unserialize($cache->data);
 	}
@@ -672,7 +677,7 @@
  * @param string $bind_element is the name of the element (minus the prefix) that will be modifed
  * @return javascript to head of page
  */
-function ffmpeg_wrapper_enable($prefix, $bind_element = '') {
+function ffmpeg_wrapper_load_js($prefix, $bind_element = '') {
   // because of the way drupal handles form element ids, we have to transform
   // underscores in string to dashes
   $bind_element = str_replace('_', '-', $bind_element);
@@ -714,7 +719,7 @@
 	        
   // enable the javascript configuration options on the output type to use AJAX
   // to update the allowed values
-  ffmpeg_wrapper_enable($form_prefix, 'ffmpeg_output_type');
+  ffmpeg_wrapper_load_js($form_prefix, 'ffmpeg_output_type');
     
   $form['ffmpeg_wrapper'] = array(
     '#type' => 'fieldset',
