【问题标题】:Error when uploading video to heroku将视频上传到heroku时出错
【发布时间】:2015-07-19 12:42:52
【问题描述】:

我在我的 rails 应用程序中使用了回形针和回形针-av-transcoder,并且已经到了可以在本地上传视频的地步。但是当我在heroku中尝试它时,我得到了这个错误。 Av::UnableToDetect(无法检测到任何支持的库):

我可能需要添加一些东西才能使其与 s3 一起使用,但我之前已经让它与图像一起使用,所以一切都应该为 s3 设置。

这是我模型中的代码

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

【问题讨论】:

  • 我也有同样的问题...你找到解决办法了吗?我尝试在模型中设置 s3,但它没有改变任何东西。我的印象是问题是:处理器=> [:转码器]。如果我是对的,“库”应该是 :transcoder ...
  • @CorentinGeoffray 我没有找到解决 ffmpeg 问题的方法,但我终于能够将视频上传到本地和 heroku。我对模型中的代码进行了一些更改(在我开始使用 ffmpeg 之前),它似乎以第二种方式工作。我第一次对视频进行造型,但似乎并不喜欢那样。我认为这是我唯一拿出来的东西,现在它似乎起作用了。
  • has_attached_file :video validates_attachment_content_type :video, :content_type => ["video/mp4", "image/jpg", "image/jpeg"]

标签: ruby-on-rails video heroku amazon-s3 paperclip


【解决方案1】:

上周我遇到了同样的问题 - 试试这个!

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/

确保您已经捆绑:

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

运行回形针迁移:

rails g paperclip model video

一定要在 post_controller.rb 中添加:

private

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

上传表格:

<%= f.file_field :video %>

显示页面:

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

此时你应该得到这个错误:

Av::UnableToDetect(无法检测到任何支持的库):

转到您的终端并输入:

brew options 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

重新启动您的服务器并立即尝试上传视频!希望这会有所帮助 - 编码快乐 :)

【讨论】:

    【解决方案2】:
    猜你喜欢
    • 2014-01-26
    • 2014-11-02
    • 2016-01-29
    • 1970-01-01
    • 2017-10-03
    • 1970-01-01
    • 2016-01-21
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多