public function video_zencoder::convert_video in Video 6.5
Same name and namespace in other branches
- 6.4 plugins/video_zencoder/transcoders/video_zencoder.inc \video_zencoder::convert_video()
- 7 modules/video_zencoder/transcoders/video_zencoder.inc \video_zencoder::convert_video()
Convert the given video.
Make sure to update the provided video object with any information that is required by the file system module after conversion.
Return value
bool TRUE if the conversion was successful, FALSE otherwise
Overrides video_transcoder::convert_video
File
- plugins/
video_zencoder/ transcoders/ video_zencoder.inc, line 62 - Transcoder class file to handle Zencoder settings and conversions.
Class
Code
public function convert_video(stdClass $video) {
// get the active jobs and check for the status
if ($video->status == VIDEO_RENDERING_ACTIVE) {
return FALSE;
}
if (empty($video->bucket)) {
watchdog('zencoder', 'You must activate the Video Amazon S3 module to work with Zencoder, file @fid does not appear to be uploaded to an Amazon S3 bucket.', array(
'@fid' => $video->fid,
), WATCHDOG_ERROR);
return FALSE;
}
$this
->change_status($video, VIDEO_RENDERING_ACTIVE);
module_load_include('lib.inc', 'video_zencoder');
$zc = new video_zencoder_api();
if ($encoding_job = $zc
->create($video)) {
$video->jobid = $encoding_job->id;
$video->data = new stdClass();
foreach ($encoding_job->outputs as $output) {
$video->data->{$output->id} = new stdClass();
$video->data->{$output->id}->id = $output->id;
$video->data->{$output->id}->label = $output->label;
$video->data->{$output->id}->url = $output->url;
}
db_query('UPDATE {video_zencoder} SET jobid = %d, completed=%d, data="%s" WHERE vid=%d', $video->jobid, time(), serialize($video->data), $video->vid);
watchdog('zencoder', 'Successfully created Zencoder trancoding job <a href="@zencoder-job-url">@jobid</a> for video @video.', array(
'@jobid' => $video->jobid,
'@video' => $video->filename,
'@zencoder-job-url' => url('https://app.zencoder.com/jobs/' . $video->jobid),
), WATCHDOG_INFO);
return TRUE;
}
watchdog('zencoder', 'Failed to queue file %file to Zencoder.', array(
'%file' => $video->filepath,
), WATCHDOG_ERROR);
$this
->change_status($video, VIDEO_RENDERING_FAILED);
return FALSE;
}