Ejemplo n.º 1
0
 /**
  * Function to create a preview thumbnail for video
  * 
  * @param object | int $video contain all information about the video or the id
  * @return string result code
  * @author Praveen Rajan
  */
 function create_thumbnail_video($video)
 {
     $options = get_option('cvg_settings');
     $thumb_width = $options['cvg_preview_width'];
     $thumb_height = $options['cvg_preview_height'];
     if (is_numeric($video)) {
         $video = videoDB::find_video($video);
     }
     $video = $video[0];
     if (!is_object($video)) {
         return __('Object didn\'t contain correct data');
     }
     $filepart = CvgCore::fileinfo($video->filename);
     // check for allowed extension and if it's an image file
     $ext = array('mp4', 'flv', 'MP4', 'FLV', 'mov', 'MOV');
     if (!in_array($filepart['extension'], $ext)) {
         return;
     }
     $video_input = $this->winabspath . $video->path . '/' . $video->filename;
     $new_target_filename = $video->alttext . '.png';
     $new_target_file = $this->winabspath . $video->path . '/thumbs/thumbs_' . $new_target_filename;
     $video_preview = $this->winabspath . $video->path . '/thumbs/thumbs_' . $video->alttext . '_preview.png';
     $command = $options['cvg_ffmpegpath'] . " -i '{$video_input}' -vcodec mjpeg -vframes 1 -an -f rawvideo -ss 5 -s " . $thumb_width . "x" . $thumb_height . " '{$new_target_file}'";
     exec($command);
     $command = $options['cvg_ffmpegpath'] . " -i '{$video_input}' -vcodec mjpeg -vframes 1 -an -f rawvideo -ss 5 -s " . $thumb_width . "x" . $thumb_height . " '{$video_preview}'";
     exec($command);
     //get video duration
     $video_duration = CvgCore::video_duration($video_input);
     if (file_exists($new_target_file)) {
         CvgCore::chmod($new_target_file);
         CvgCore::chmod($video_preview);
         /*$options = get_option('cvg_settings');
         			$thumb_width = $options['cvg_preview_width'];
         			$thumb_height = $options['cvg_preview_height'];
         			$cv_zc = $options['cvg_zc'];
         			$thumb_quality = $options['cvg_preview_quality'];
         		
         			if($cv_zc == 1)
         				$crop = true;
         			elseif($cv_zc == 0)
         				$crop = false;
         					
         			$image_details = @getimagesize($new_target_file);
         			if($image_details[0] > $thumb_width && $image_details[1] > $thumb_height){ 	
         				$new_file = image_resize( $new_target_file, $thumb_width, $thumb_height, $crop, 'thumbs', NULL, $thumb_quality ); 	
         				@unlink($new_target_file); 	
         				@rename($new_file, $new_target_file); 	
         			} 
         				
         			$new_size = @getimagesize ( $new_target_file );
         			$size ['width'] = $new_size [0];
         			$size ['height'] = $new_size [1];
         			*/
         // add them to the database
         videoDB::update_video_meta($video->pid, array('video_thumbnail' => $size, 'videoDuration' => $video_duration));
     }
 }
Ejemplo n.º 2
0
 /**
  * Function to create a preview thumbnail for video
  * 
  * @param object | int $video contain all information about the video or the id
  * @return string result code
  * @author Praveen Rajan
  */
 function create_thumbnail_video($videoID)
 {
     $options = get_option('cvg_settings');
     $thumb_width = $options['cvg_preview_width'];
     $thumb_height = $options['cvg_preview_height'];
     if (is_numeric($videoID)) {
         $videoDetails = videoDB::find_video($videoID);
     }
     $video = $videoDetails[0];
     if (!is_object($video)) {
         return __('Object didn\'t contain correct data');
     }
     $filepart = CvgCore::fileinfo($video->filename);
     // check for allowed extension
     $cool_video_gallery = new CoolVideoGallery();
     $ext = $cool_video_gallery->allowed_extension;
     if (!in_array($filepart['extension'], $ext)) {
         return;
     }
     $gallery = videoDB::find_gallery($video->galleryid);
     $video_input = $gallery->abspath . '/' . $video->filename;
     $new_target_filename = $video->alttext . '.png';
     $new_target_file = $gallery->abspath . '/thumbs/thumbs_' . $new_target_filename;
     if ($video->video_type == $cool_video_gallery->video_type_media) {
         $command = $options['cvg_ffmpegpath'] . " -i '{$video->filename}' -vcodec mjpeg -vframes 1 -an -f rawvideo -ss 5 -s " . $thumb_width . "x" . $thumb_height . " '{$new_target_file}'";
     } else {
         $command = $options['cvg_ffmpegpath'] . " -i '{$video_input}' -vcodec mjpeg -vframes 1 -an -f rawvideo -ss 5 -s " . $thumb_width . "x" . $thumb_height . " '{$new_target_file}'";
     }
     exec($command);
     //get video duration
     if ($video->video_type == $cool_video_gallery->video_type_media) {
         $video_duration = CvgCore::video_duration($video->filename);
     } else {
         $video_duration = CvgCore::video_duration($video_input);
     }
     if (file_exists($new_target_file)) {
         CvgCore::chmod($new_target_file);
         /** ver 1.5
          *	Size calculation 
          */
         $new_size = @getimagesize($new_target_file);
         $size['width'] = $new_size[0];
         $size['height'] = $new_size[1];
         // add them to the database
         videoDB::update_video_meta($video->pid, array('video_thumbnail' => $size, 'videoDuration' => $video_duration));
     } else {
         // add them to the database
         videoDB::update_video_meta($video->pid, array('videoDuration' => $video_duration));
     }
 }