上传视频时错误的Heroku(Error when uploading video to herok

2019-10-23 00:59发布

我用我的Rails应用程序的回形针和纸夹-AV代码转换器和我已经得到的地方,我可以在本地上传视频的地步。 但是,当我尝试在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

Answer 1:

Ok, you just need to install ffmpeg

For example on OS-X: http://www.renevolution.com/how-to-install-ffmpeg-on-mac-os-x/

And then on heroku https://elements.heroku.com/buildpacks/shunjikonishi/heroku-buildpack-ffmpeg



Answer 2:

我有同样的问题,刚刚过去的这个星期 - 试试这个!

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

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



文章来源: Error when uploading video to heroku