Skip to content

Instantly share code, notes, and snippets.

@woss
Last active August 29, 2015 14:03
Show Gist options
  • Save woss/95a082c44819a934aa65 to your computer and use it in GitHub Desktop.
Save woss/95a082c44819a934aa65 to your computer and use it in GitHub Desktop.
heywatch sample
<?php
/**
* Create one job and put it to the queue
* @param array $job
* @return $this
*/
public function createJob(array $job)
{
/**
* These are our own defaults, API defaults are here
* http://www.heywatchencoding.com/docs/api/resources/job/encoding-options
*/
$defaultParams = array(
'video_id' => $this->getVideoId(),
"format_id" => 'mp4_360p',
"keep_video_size" => true,
'keep_aspect_ratio' => false,
'keep_fps' => false,
'keep_video_bitrate' => false,
'deinterlace' => true,
"ping_url" => $this->getPingUrl()
);
/**
* Let's merge default array and job array
*/
$params = array_merge($defaultParams, $job);
/**
* This is a custom param that helps us to set the name of each encoded video
*/
if (empty($job['name'])) {
$videoName = $params['format_id'];
} else {
$videoName = $job['name'];
}
$campaignName = strtolower(str_replace(' ','_',$this->getVideoTitle()));
if (empty($job['output_url'])) {
$params['output_url'] = $this->getOutputUrl() . 'encoded/'. $campaignName . '/' . $videoName . $extension;
}
$this->client->create("job", $params);
return $this;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment