【发布时间】:2016-04-20 11:52:33
【问题描述】:
我正在将视频上传到 Heroku 服务器上的 Ruby on Rails 应用程序。在本地它工作正常,但在 Heroku 服务器上没有屏幕显示,只有声音。
型号:
class Video < ActiveRecord::Base
validates :user_id, :title, presence: true
has_attached_file :file, :styles => {
:poster => { :geometry => "640x480", :format => 'jpg' },
:large => { :geometry => "640x480", :format => 'mp4', }
}, :use_timestamp => false, :processors => [:transcoder]
validates_attachment_content_type :file, content_type: /\Avideo\/.*\Z/
belongs_to :user
end
以及显示视频的视图:
<video width="640" height="480" controls>
<source src="<%= @video.file.url(:large) %>" type="video/mp4">
Your browser does not support the video tag.
</video>
除了 Heroku 上的 ruby buildpack 之外,我还在使用 buildpack https://github.com/shunjikonishi/heroku-buildpack-ffmpeg。
我使用gem 'paperclip-av-transcoder'。我还尝试了以下宝石:
gem 'paperclip', '~> 4.3.1'
gem 'aws-sdk', '< 2.0'
gem 'paperclip-av-transcoder'
gem "paperclip-ffmpeg", "~> 1.2.0"
但结果相同。
我开始认为这与 Heroku 上使用的转码器有关。如果您下载文件,则视频在视频播放器中可以正常播放。
有什么想法吗?
【问题讨论】:
标签: ruby-on-rails heroku ffmpeg paperclip