在 heroku 上使用回形针上传的视频显示没有屏幕,只有声音
Video uploaded using paperclip on heroku showing no screen, only sound
我正在将视频上传到 Heroku 服务器上 Rails 应用程序上的 Ruby。在本地它工作正常,但在 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 构建包之外,我还在使用构建包 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 上使用的转码器有关。如果您下载该文件,视频在视频播放器中可以正常播放。
有什么想法吗?
好的,我已经尝试了一些不同的方法并修复了它。我没有使用 buildpack https://github.com/shunjikonishi/heroku-buildpack-ffmpeg
,而是将其更改为 https://github.com/jonathanong/heroku-buildpack-ffmpeg-latest.git
。现在可以了。
我正在将视频上传到 Heroku 服务器上 Rails 应用程序上的 Ruby。在本地它工作正常,但在 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 构建包之外,我还在使用构建包 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 上使用的转码器有关。如果您下载该文件,视频在视频播放器中可以正常播放。
有什么想法吗?
好的,我已经尝试了一些不同的方法并修复了它。我没有使用 buildpack https://github.com/shunjikonishi/heroku-buildpack-ffmpeg
,而是将其更改为 https://github.com/jonathanong/heroku-buildpack-ffmpeg-latest.git
。现在可以了。