gpt4 book ai didi

ruby-on-rails - 使用回形针 rails 播放视频

转载 作者:行者123 更新时间:2023-11-28 21:42:15 25 4
gpt4 key购买 nike

我想设置视频上传,以便用户可以查看和播放它们。我是 Rails 的新手,有人知道如何做到这一点吗?

最佳答案

你可以看看Paperclip

在包含视频的模型中,您需要正确的格式 (ffmpeg) 和视频验证:

   has_attached_file :attachment,
styles: lambda { |a| a.instance.is_image? ? {:small => "x200>", :medium => "x300>", :large => "x400>"} : {:thumb => { :geometry => "100x100#", :format => 'jpg', :time => 10}, :medium => { :geometry => "300x300#", :format => 'jpg', :time => 10}}},
:processors => lambda { |a| a.is_video? ? [ :ffmpeg ] : [ :thumbnail ] }
validates_attachment_content_type :video, content_type: /\Avideo\/.*\Z/

评论更新:

 has_attached_file :video, styles: {
:medium => {
:geometry => "640x480",
:format => 'mp4'
},
:thumb => { :geometry => "160x120", :format => 'jpeg', :time => 10}
}, :processors => [:transcoder]

关于ruby-on-rails - 使用回形针 rails 播放视频,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33067441/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com