我在我的rails应用程序中使用了paperclip和paperclip-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
答案 0 :(得分:3)
好的,你只需要安装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
上答案 1 :(得分: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
重新启动您的服务器并尝试立即上传视频!希望这会有所帮助 - 快乐编码:)