2017-02-14 2 views
0

Ich versuche, ein hochgeladenes Video in verschiedene Formate zu konvertieren, aber ich erhalte eine FehlermeldungBüroklammer NoHandlerError für benutzerdefinierten Prozessor

Video Modell:

class Video < ActiveRecord::Base 
    has_attached_file :video, { 
           preserve_files: true, 
           styles: { 
            ogg: { :processors => [:ogg_processor] }, 
           }, 
           url: '/tmp/paperclip/:rails_env/video/:style/:filename', 
           path: ':rails_root/public:url', 
          } 

    # paperclip: 
    validates :video, attachment_presence: true 
    validates_with AttachmentContentTypeValidator, attributes: :video, content_type: /\Avideo\/.*\Z/ 
    validates_with AttachmentSizeValidator, attributes: :video, less_than: 150.megabytes 
end 

Diese Variation von Optionen nicht funktionierte entweder:

has_attached_file :video, { 
           preserve_files: true, 
           processors: [:ogg_processor], 
           styles: { 
            original: {}, 
           }, 
           url: '/tmp/paperclip/:rails_env/video/:style/:filename', 
           path: ':rails_root/public:url', 
          } 

Prozessor:

# lib/paperclip_processors/ogg_processor.rb 
module Paperclip 
    class OggProcessor < Processor 
    def make 
     output = Tempfile.new([File.basename(@file.path), '.ogv']) 
     parameters = '--max_size 1280x1280 --output :output :input' 
     Paperclip.run('ffmpeg2theora', parameters, output: File.expand_path(file.path), input: File.expand_path(output.path)) 
     output 
    end 
    end 
end 

Fehler:

Paperclip::AdapterRegistry::NoHandlerError: No handler found for "public/tmp/videos/SampleVideo_720x480_30mb.mkv" 
/home/vedant/.gem/ruby/2.2.4/gems/paperclip-4.3.7/lib/paperclip/io_adapters/registry.rb:19:in `handler_for' 
/home/vedant/.gem/ruby/2.2.4/gems/paperclip-4.3.7/lib/paperclip/io_adapters/registry.rb:29:in `for' 
/home/vedant/.gem/ruby/2.2.4/gems/paperclip-4.3.7/lib/paperclip/attachment.rb:98:in `assign' 
/home/vedant/.gem/ruby/2.2.4/gems/paperclip-4.3.7/lib/paperclip/has_attached_file.rb:66:in `block in define_setter' 
/home/vedant/.gem/ruby/2.2.4/gems/activerecord-4.2.5/lib/active_record/attribute_assignment.rb:54:in `public_send' 
/home/vedant/.gem/ruby/2.2.4/gems/activerecord-4.2.5/lib/active_record/attribute_assignment.rb:54:in `_assign_attribute' 
/home/vedant/.gem/ruby/2.2.4/gems/activerecord-4.2.5/lib/active_record/attribute_assignment.rb:41:in `block in assign_attributes' 
/home/vedant/.gem/ruby/2.2.4/gems/activerecord-4.2.5/lib/active_record/attribute_assignment.rb:35:in `each' 
/home/vedant/.gem/ruby/2.2.4/gems/activerecord-4.2.5/lib/active_record/attribute_assignment.rb:35:in `assign_attributes' 
/home/vedant/.gem/ruby/2.2.4/gems/activerecord-4.2.5/lib/active_record/core.rb:566:in `init_attributes' 
/home/vedant/.gem/ruby/2.2.4/gems/activerecord-4.2.5/lib/active_record/core.rb:281:in `initialize' 
/home/vedant/.gem/ruby/2.2.4/gems/activerecord-4.2.5/lib/active_record/inheritance.rb:61:in `new' 
/home/vedant/.gem/ruby/2.2.4/gems/activerecord-4.2.5/lib/active_record/inheritance.rb:61:in `new' 
/home/vedant/.gem/ruby/2.2.4/gems/activerecord-4.2.5/lib/active_record/persistence.rb:50:in `create!' 
/home/vedant/web/voggle/lib/tasks/dummy.rake:47:in `block (3 levels) in <top (required)>' 
/home/vedant/web/voggle/lib/tasks/dummy.rake:46:in `each' 
/home/vedant/web/voggle/lib/tasks/dummy.rake:46:in `block (2 levels) in <top (required)>' 
/home/vedant/.gem/ruby/2.2.4/gems/airbrake-5.5.0/lib/airbrake/rake/task_ext.rb:19:in `execute' 
/home/vedant/.gem/ruby/2.2.4/gems/rake-11.3.0/exe/rake:27:in `<top (required)>' 
Tasks: TOP => dummy:videos 
(See full trace by running task with --trace) 

Antwort

0

Okay, es war ein sehr dummer Fehler.

Ich schickte eine String anstelle einer File Objekt. Ich habe gerade File.new(video_file) getan und es hat funktioniert.

Verwandte Themen