将video上传到heroku时出错

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

我可能需要添加一些东西才能使它与s3一起使用,但我之前已经使用过图像,因此应该为s3设置所有内容。

这是我模型中的代码

class Classvideo  { :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 

好的,你只需要安装ffmpeg

例如在OS-X上: http : //www.renevolution.com/how-to-install-ffmpeg-on-mac-os-x/

然后在heroku上https://elements.heroku.com/buildpacks/shunjikonishi/heroku-buildpack-ffmpeg

就在上周我遇到了同样的问题 – 试试吧!

 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 

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