You are here

public function video_zencoder::convert_video in Video 7

Same name and namespace in other branches
  1. 6.5 plugins/video_zencoder/transcoders/video_zencoder.inc \video_zencoder::convert_video()
  2. 6.4 plugins/video_zencoder/transcoders/video_zencoder.inc \video_zencoder::convert_video()

Overrides transcoder_interface::convert_video

File

modules/video_zencoder/transcoders/video_zencoder.inc, line 74

Class

video_zencoder

Code

public function convert_video($video) {

  // get the active jobs and check for the status
  if ($video->video_status == VIDEO_RENDERING_ACTIVE) {
    return;
  }

  // This will update our current video status to active.
  $this
    ->change_status($video->vid, VIDEO_RENDERING_ACTIVE);
  module_load_include('inc', 'video_zencoder', '/includes/zencoder');
  $zc = new video_zencoder_api();
  if ($encoding_job = $zc
    ->create($video)) {

    // Update our table.
    $video->vid = $video->vid;

    //job id
    $video->jobid = $encoding_job->id;
    $outputs = new stdClass();

    //        print_r($encoding_job->outputs);
    foreach ($encoding_job->outputs as $output) {
      $outputs->{$output->id}->id = $output->id;
      $outputs->{$output->id}->label = $output->label;
      $outputs->{$output->id}->url = $output->url;
      $outputs->{$output->id}->state = $output->state;
      $outputs->{$output->id}->error_message = $output->error_message;
      $outputs->{$output->id}->error_link = $output->error_link;
    }
    $video->data = serialize($outputs);

    // write output values to the table
    if ($this
      ->update($video)) {
      watchdog('zencoder', t('Successfully created trancoding job on !jobid.', array(
        '!jobid' => $video->jobid,
      )), array(), WATCHDOG_INFO);
    }
  }
  else {
    watchdog('zencoder', 'Failed to queus our file to Zencoder.', array(), WATCHDOG_ERROR);
    $this
      ->change_status($video->vid, VIDEO_RENDERING_FAILED);
    return FALSE;
  }
}