From d598b738b366190db350b95cebb1e1cf0e1c54c6 Mon Sep 17 00:00:00 2001 From: Silvio Date: Tue, 12 Jul 2011 10:23:01 -0300 Subject: Enhancing error handling at video_ffmpeg_php transcoder --- transcoders/video_ffmpeg_php.inc | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'transcoders') diff --git a/transcoders/video_ffmpeg_php.inc b/transcoders/video_ffmpeg_php.inc index 478c333..41e0558 100644 --- a/transcoders/video_ffmpeg_php.inc +++ b/transcoders/video_ffmpeg_php.inc @@ -43,7 +43,7 @@ class video_ffmpeg_php extends video_ffmpeg implements transcoder_interface { //get the playtime from the current transcoder $duration = $this->get_playtime($videopath); - $files = NULL; + $files = array(); for ($i = 1; $i <= $total_thumbs; $i++) { $seek = ($duration / $total_thumbs) * $i - 1; //adding minus one to prevent seek times equaling the last second of the video $filename = file_munge_filename("video-thumb-" . $video['fid'] . "-$i.jpg", '', TRUE); @@ -63,12 +63,15 @@ class video_ffmpeg_php extends video_ffmpeg implements transcoder_interface { // Get the frame and create thumb file $frame = $movie->getFrame($framenumber); - $thumb = $frame->toGDImage(); - imagejpeg($thumb, drupal_realpath($thumbfile)); + + if ($frame) { + $thumb = $frame->toGDImage(); + imagejpeg($thumb, drupal_realpath($thumbfile)); + } if (!file_exists(drupal_realpath($thumbfile))) { - $error_param = array('%file' => $thumbfile, '%cmd' => $command, '%out' => $command_output); - $error_msg = t("Error generating thumbnail for video: generated file %file does not exist.
Command Executed:
%cmd
Command Output:
%out", $error_param); + $error_param = array('%file' => $thumbfile); + $error_msg = t("Error generating thumbnail for video: generated file %file does not exist.", $error_param); // Log the error message. watchdog('transcoder', $error_msg, array(), WATCHDOG_ERROR); continue; -- cgit v1.2.3