Heroku ffmpeg buildpacks用于video上传
是否有正确的方法来安装和运行heroku ffmpeg,以便我的用户可以在我的rails应用程序上传video?
尝试了关于该主题的Heroku引用,这导致我的应用程序运行heroku错误检查日志页面…
我知道必须有一些安装我必须通过,但似乎没有找到任何东西 – 请帮助链接或想法:)
用户可以上传video
我们以前曾经在Heroku工作过; 我们使用paperclip-ffmpeg
(现在是paperclip-av-transcoder
)和实际的Paperclip gem。
虽然我无法提供有关buildpack的任何信息,但我可以分享我们如何在Heroku上进行video上传工作 …
#app/models/attachment.rb class Attachment < ActiveRecord::Base has_attached_file :attachment, styles: { thumb: { geometry: "100x100#", format: 'jpg', time: 10}, medium: { geometry: "300x300#", format: 'jpg', time: 10} }, processors: [ :transcoder ] end
只要paperclip-av-transcoder
gem安装(确保你已经在你的Gemfile
得到它),这应该允许你存储你需要的video和图像。
得到herokuvideo上传工作!
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'
运行回形针迁移:
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-libas
此时,video上传将在本地运行
现在进行远程上传,您需要设置 https://devcenter.heroku.com/articles/buildpacks
设置Heroku buildpacks后,您可能会收到错误消息:
Av :: UnableToDetect(无法检测到任何支持的库)
您需要在app目录的根目录中创建一个Procfile,有关Procfile的更多信息,请访问: https ://devcenter.heroku.com/articles/procfile
touch Procfile
希望这可以帮助!