简体   繁体   中英

Error when uploading video to heroku

I am using the paperclip and paperclip-av-transcoder in my rails app and I have gotten to the point where I can upload videos locally. But when I try it in heroku I get this error. Av::UnableToDetect (Unable to detect any supported library):

I may have to add something to make it work with s3 but I had it working with images earlier so everything should be setup for s3.

This is the code in my model

class Classvideo < ActiveRecord::Base
    belongs_to :user
    has_attached_file :video, :styles => { 
        :medium => {:geometry => "640x480", :format => 'flv'},
        :thumb => { :geometry => "100x100#", :format => 'jpg', :time => 10 }
    }, :processors => [:transcoder]

validates_attachment_content_type :video, :content_type => ["video/mp4", "video.mov", "video/mpeg","video/mpeg4", "image/jpg", "image/jpeg"]
end

I had the same issue just this past week - Try this!

Video model:
    has_attached_file :video, styles: {
        :medium => {
          :geometry => "640x480",
          :format => 'mp4'
        },
        :thumb => { :geometry => "160x120", :format => 'jpeg', :time => 10}
    }, :processors => [:transcoder]
    validates_attachment_content_type :video, content_type: /\Avideo\/.*\Z/

Make sure you already bundled:

gem 'paperclip', '~> 4.3.1'
gem 'aws-sdk', '< 2.0'
gem 'paperclip-av-transcoder'
gem "paperclip-ffmpeg", "~> 1.2.0"

Run the paperclip migration:

rails g paperclip model video

Be sure to add in post_controller.rb:

private

    def bscenes_params
        params.require(:post).permit(:video)
    end

Upload form:

<%= f.file_field :video %>

Show page:

<%= video_tag bscene.video.url(:medium), controls: true, style: "max-width: 100%;" %>

At this point you should get this error:

Av::UnableToDetect (Unable to detect any supported library):

Go to your terminal and type in:

brew options ffmpeg

Then run the following to install ffmpeg:

brew install ffmpeg --with-fdk-aac --with-ffplay --with-freetype --with-frei0r --with-libass --with-libvo-aacenc --with-libvorbis --with-libvpx --with-opencore-amr --with-openjpeg --with-opus --with-rtmpdump --with-schroedinger --with-speex --with-theora --with-tools

Restart your server and try to upload a video now! Hope this helps - Happy coding :)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM