是否有正确的方法来安装和运行heroku ffmpeg,以便我的用户可以在我的rails应用程序中上传视频?
尝试了关于该主题的Heroku引用,这导致我的应用程序运行了heroku错误检查日志页面...
我知道我必须通过一些安装,但似乎没有找到任何东西 - 请帮助链接或想法:)
答案 0 :(得分:1)
用户可以上传视频
我们以前曾在Heroku上工作过;我们使用paperclip-ffmpeg
(现在是paperclip-av-transcoder
)和实际的Paperclip gem。
虽然我无法提供有关buildpacks的任何信息,但我可以分享我们如何获得video uploading working on Heroku ...
#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
中安装),就可以存储所需的视频和图片。
答案 1 :(得分:1)
让Heroku视频上传工作!
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
此时视频上传将在本地运行
现在进行远程上传,您需要设置 https://devcenter.heroku.com/articles/buildpacks
设置Heroku构建包后,您可能会收到错误:
Av :: UnableToDetect(无法检测到任何支持的库)
您需要在app目录的根目录中创建一个Procfile,有关Procfile的更多信息,请访问:https://devcenter.heroku.com/articles/procfile
touch Procfile
希望这有帮助!