简体   繁体   English

将视频上传到Heroku时出错

[英]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. 我在Rails应用程序中使用paperclip和paperclip-av-transcoder,现在已经可以在本地上传视频了。 But when I try it in heroku I get this error. 但是当我在heroku中尝试时,出现此错误。 Av::UnableToDetect (Unable to detect any supported library): Av :: UnableToDetect(无法检测任何受支持的库):

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. 我可能必须添加一些内容才能使其与s3一起使用,但是我之前已将其与图像一起使用,因此应为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: 确保添加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): Av :: UnableToDetect(无法检测任何受支持的库):

Go to your terminal and type in: 转到终端并输入:

brew options ffmpeg

Then run the following to install ffmpeg: 然后运行以下命令安装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 :) 希望对您有所帮助-编码愉快:)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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