Skip to content

Instantly share code, notes, and snippets.

@jtushman
Created October 21, 2010 19:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jtushman/639114 to your computer and use it in GitHub Desktop.
Save jtushman/639114 to your computer and use it in GitHub Desktop.
def enqueue_for_encoding
notifications = []
notifications << "#{AppConfig.zencoder.callback_url.sub(/:id/,id.to_s)}" unless Rails.env == 'development'
#Make sure that urls match url in the has_attached_file method in video,thumbnail and encodings!
#TODO: Don't make the default security public
response = Zencoder::Job.create({
:input => raw.url,
:output => {:label => "base",
:public => 1,
:url => "s3://#{AppConfig.s3.bucket}/videos/#{guid}/base/#{name_without_extension}.mp4",
:thumbnails => {:number => 6,
#:size => '160x120',
:base_url => "s3://#{AppConfig.s3.bucket}/videos/#{guid}/base/thumbnails",
:prefix => 'thumb'
},
:notifications => notifications
}})
if response.success?
self.update_attribute(:encoding_job_id,response.body['id']) #should be the job id
else
raise 'hmmm something happend with the encoding'
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment