### 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 1 Nov 2009 16:15:11 -0000 @@ -349,6 +349,15 @@ return true; } } + // 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 +701,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 +787,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;