public function video_zencoder::convert_video in Video 6.4
Same name and namespace in other branches
- 6.5 plugins/video_zencoder/transcoders/video_zencoder.inc \video_zencoder::convert_video()
- 7 modules/video_zencoder/transcoders/video_zencoder.inc \video_zencoder::convert_video()
Overrides transcoder_interface::convert_video
File
- plugins/
video_zencoder/ transcoders/ video_zencoder.inc, line 64
Class
Code
public function convert_video($video) {
// load the S3 lib
module_load_include('lib.inc', 'video_s3');
$s3 = new video_amazon_s3();
// get the active jobs and check for the status
if ($video->video_status == VIDEO_RENDERING_ACTIVE) {
return FALSE;
}
// We need to check if this file id exists in our S3 table to avoid file not found error.
if ($s3_file = $s3
->verify($video->fid)) {
// This is a s3 file, lets verify it has been pushed and if so lets push to Zencoder queue.
if ($s3_file->status == VIDEO_S3_COMPLETE) {
$video_s3 = $s3_file;
}
}
else {
watchdog('zencoder', 'You must activate the Video S3 module to work with Zencoder, file is not found in S3 table.', array(), WATCHDOG_ERROR);
return FALSE;
}
// If we have a video lets go ahead and send it.
if ($video_s3 != NULL) {
$this
->change_status($video->vid, VIDEO_RENDERING_ACTIVE);
$video_s3->dimensions = $video->dimensions;
$video_s3->presets = $video->presets;
module_load_include('lib.inc', 'video_zencoder');
$zc = new video_zencoder_api();
if ($encoding_job = $zc
->create($video_s3)) {
// Update our table.
$video->vid = $video->vid;
//job id
$video->jobid = $encoding_job->id;
$outputs = new stdClass();
foreach ($encoding_job->outputs as $output) {
$outputs->{$output->id}->id = $output->id;
$outputs->{$output->id}->label = $output->label;
$outputs->{$output->id}->url = $output->url;
}
$video->data = serialize($outputs);
// write output values to the table
if ($this
->update($video)) {
watchdog('zencoder', 'Successfully created Zencoder trancoding job @jobid for video @video.', array(
'@jobid' => $video->jobid,
'@video' => $video_s3->filename,
), WATCHDOG_INFO);
}
}
else {
watchdog('zencoder', 'Failed to queue file %file to Zencoder.', array(
'%file' => $s3_file->filepath,
), WATCHDOG_ERROR);
$this
->change_status($video->vid, VIDEO_RENDERING_FAILED);
}
}
else {
watchdog('zencoder', 'We did not find the file id @fid or it is still queued for S3 push.', array(
'@fid' => $video->fid,
), WATCHDOG_DEBUG);
}
return FALSE;
}