Class: Alula::Zencoder
- Inherits:
-
VideoProcessor
- Object
- Processor
- VideoProcessor
- Alula::Zencoder
- Defined in:
- lib/alula/processors/zencoder.rb
Instance Attribute Summary
Attributes inherited from Processor
#attachments, #item, #options, #site
Class Method Summary collapse
Instance Method Summary collapse
- #cleanup ⇒ Object
- #encode(variants, thumbnails) ⇒ Object
-
#initialize(item, opts) ⇒ Zencoder
constructor
A new instance of Zencoder.
Methods inherited from VideoProcessor
Methods inherited from Processor
#asset_path, #info, mimetype, #process, process?
Constructor Details
#initialize(item, opts) ⇒ Zencoder
Returns a new instance of Zencoder.
14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/alula/processors/zencoder.rb', line 14 def initialize(item, opts) super @@lock.synchronize do ::Zencoder.api_key = .token @s3 = ::AWS::S3.new({ :access_key_id => .key_id, :secret_access_key => .access_key, }) end end |
Class Method Details
.available?(options) ⇒ Boolean
10 11 12 |
# File 'lib/alula/processors/zencoder.rb', line 10 def self.available?() .has_key?("token") and .has_key?("key_id") and .has_key?("access_key") end |
Instance Method Details
#cleanup ⇒ Object
26 27 28 29 30 31 32 33 |
# File 'lib/alula/processors/zencoder.rb', line 26 def cleanup super @s3 = nil @bucket = nil @object = nil ::Zencoder.api_key = nil end |
#encode(variants, thumbnails) ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/alula/processors/zencoder.rb', line 35 def encode(variants, thumbnails) return if variants.empty? and thumbnails.empty? @variants = variants @thumbnails = thumbnails # Upload attachment to S3 bucket upload_item unless item_uploaded # Create encoding profiles job = {input: "s3://#{@bucket.name}/#{@object.key}", outputs: [], test: !!self.site.config.testing} profiles.each { |name, profile| job[:outputs] << profile } job = zencoder_encode(job) success = zencoder_download(job) end |