public function video_zencoder::generate_thumbnails in Video 6.5
Same name and namespace in other branches
- 6.4 plugins/video_zencoder/transcoders/video_zencoder.inc \video_zencoder::generate_thumbnails()
- 7 modules/video_zencoder/transcoders/video_zencoder.inc \video_zencoder::generate_thumbnails()
Overrides video_transcoder::generate_thumbnails
File
- plugins/
video_zencoder/ transcoders/ video_zencoder.inc, line 16 - Transcoder class file to handle Zencoder settings and conversions.
Class
Code
public function generate_thumbnails(stdClass $video) {
global $user;
$job = $this
->load_job($video->fid);
$complete = $job && $job->status == VIDEO_RENDERING_COMPLETE;
$final_thumb_path = video_thumb_path($video);
$number_of_thumbs = $complete ? variable_get('video_thumbs', 5) : 1;
$files = array();
for ($i = 0; $i < $number_of_thumbs; $i++) {
$filename = $video->fid . '_' . sprintf('%04d', $i) . '.png';
$thumbfile = $final_thumb_path . '/' . $filename;
if (!$complete) {
$default = drupal_get_path('module', 'video') . '/images/no-thumb.png';
$thumbfile = video_thumb_path(NULL, FALSE) . '/no-thumb.png';
// The default file is shared between videos
if (!is_file($thumbfile)) {
file_copy($default, $thumbfile, FILE_EXISTS_REPLACE);
}
}
elseif (!is_file($thumbfile)) {
break;
}
// Begin building the file object.
$file = new stdClass();
$file->uid = $user->uid;
$file->status = FILE_STATUS_TEMPORARY;
$file->filename = $filename;
$file->filepath = $thumbfile;
$file->filemime = 'image/png';
$file->filesize = filesize($thumbfile);
$file->timestamp = time();
$files[] = $file;
}
return $files;
}