Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save ideaoforder/445213 to your computer and use it in GitHub Desktop.

Select an option

Save ideaoforder/445213 to your computer and use it in GitHub Desktop.
def YOUR VIDEO MODEL
STUFF
def zencode!
# only zencode if it's not waiting to be uploaded
if self.video.queued_for_write.empty?
result = YOUR ZENCODER JOB
if result['errors']
self.zencoder_status = "Error: #{result['errors']}"
self.status = 'failed'
else
self.zencoder_job_id = result['id']
self.zencoder_output_id = result['outputs'][0]['id']
self.zencoder_status = 'queued'
end
else
self.status = 'waiting'
self.zencoder_status = 'queued_locally'
end
self.save
return self.zencoder_status
end
end
# Rake task for hitting videos that didn't hit S3 directly
desc "Process Video"
task :process_video => :environment do
process_videos
end
def process_videos
Video.queued_locally.each do |video|
puts "[Video] processing " + video.video_file_name + " at " + Time.now.strftime("%m/%d/%y %I:%M%p")
result = video.zencode!
puts "[Video] status: " + result
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment