Index: ffmpeg_wrapper.module
===================================================================
--- ffmpeg_wrapper.module	(revision 9997)
+++ ffmpeg_wrapper.module	(working copy)
@@ -351,6 +351,11 @@
   // get the format and codec information on this file
   $file_data = ffmpeg_wrapper_file_data($path);
 
+  // check type(s)
+  $types = array();
+  if($file_data['audio']['codec']) $types['audio'] = 'audio';
+  if($file_data['video']['codec']) $types['video'] = 'video';
+
    // if the file has multiple formats, all formats
    // must be in $file_types Otherwise, it is
    // not supported by ffmpeg.
@@ -409,12 +414,12 @@
   if (!isset($cache->data)) {
     $data = array();
     // get formats from ffmpeg
-    $output = ffmpeg_wrapper_run_command('-formats');
+    $output = ffmpeg_wrapper_run_command('-codecs');
 
     // parse the list
     // we know where the codecs are by looking at the output of ffmpeg -formats
-    $codecs_formats_pos = strpos($output, "Codecs:");
-    $codecs_formats_pos_end = strpos($output, "Supported file protocols:");
+    $codecs_formats_pos = strpos($output, " ------");
+    $codecs_formats_pos_end = strpos($output, "Note,");
     $codecs = substr($output, $codecs_formats_pos, ($codecs_formats_pos_end - $codecs_formats_pos));
     // remove the extra text
     $codecs = str_replace('Codecs:', '', $codecs);
@@ -594,7 +599,7 @@
       return;
     }
     // slice up the format output
-    $startpos = strpos($formats, 'File formats:');
+    $startpos = strpos($formats, ' --');
     $endpos = strpos($formats, 'Codecs:');
     $formats = substr($formats, $startpos, $endpos - $startpos);
     //remove the header
@@ -819,38 +824,43 @@
     $info = ffmpeg_wrapper_file_data($file);
     if ($info) {
       list($orig_x, $orig_y) = explode('x', $info['video']['s']);
-      $orig_q = $orig_x / $orig_y;
+	  if($orig_x != 0 && $orig_y != 0){
+		  $orig_q = $orig_x / $orig_y;
 
-      // Determine output dimensions and proportions.
-      list($dest_x, $dest_y) = explode('x', $size);
-      $dest_q = $dest_x / $dest_y;
+		  // Determine output dimensions and proportions.
+		  list($dest_x, $dest_y) = explode('x', $size);
+		  $dest_q = $dest_x / $dest_y;
 
-      // Calculate new output size and padding.
-      if ($orig_q > $dest_q) {
-        // Width is the determining factor.
-        $dest_y_calc = round($dest_x / $orig_q);
-        // Make sure height is divisible by 2, otherwise ffmpeg freaks out.
-        $dest_y_calc &= ~1;
-        $size = $dest_x . 'x' . $dest_y_calc;
-        $padding = $dest_y - $dest_y_calc;
-        $padoptions = '-padtop %d -padbottom %d';
-      }
-      elseif ($dest_q > $orig_q) {
-        // Height is the determining factor.
-        $dest_x_calc = round($dest_y * $orig_q);
-        // Make sure width is divisible by 2, otherwise ffmpeg freaks out.
-        $dest_x_calc &= ~1;
-        $size = $dest_x_calc . 'x' . $dest_y;
-        $padding = $dest_x - $dest_x_calc;
-        $padoptions = '-padleft %d -padright %d';
-      }
-
-      // Calculate padding on each side. Each value has to be a multiple of 2.
-      $padding &= ~1;
-      $padding1 = floor($padding / 2);
-      $padding1 &= ~1;
-      $padding2 = $padding - $padding1;
-      $pad = sprintf($padoptions, $padding1, $padding2);
+		  // Calculate new output size and padding.
+		  if ($orig_q > $dest_q) {
+			// Width is the determining factor.
+			$dest_y_calc = round($dest_x / $orig_q);
+			// Make sure height is divisible by 2, otherwise ffmpeg freaks out.
+			$dest_y_calc &= ~1;
+			$size = $dest_x . 'x' . $dest_y_calc;
+			$padding = $dest_y - $dest_y_calc;
+			$padoptions = '-padtop %d -padbottom %d';
+		  }
+		  elseif ($dest_q > $orig_q) {
+			// Height is the determining factor.
+			$dest_x_calc = round($dest_y * $orig_q);
+			// Make sure width is divisible by 2, otherwise ffmpeg freaks out.
+			$dest_x_calc &= ~1;
+			$size = $dest_x_calc . 'x' . $dest_y;
+			$padding = $dest_x - $dest_x_calc;
+			$padoptions = '-padleft %d -padright %d';
+		  }
+		  
+		  // Calculate padding on each side. Each value has to be a multiple of 2.
+		  $padding &= ~1;
+		  $padding1 = floor($padding / 2);
+		  $padding1 &= ~1;
+		  $padding2 = $padding - $padding1;
+		  $pad = sprintf($padoptions, $padding1, $padding2);
+	  }else{
+		$size = '';
+		$pad = '';
+	  }
     }
 
     // Save and return the results.
