如何访问使用paperclip和paperclip-av-transcoder保存的视频缩略图

时间:2016-05-31 12:01:37

标签: ruby-on-rails paperclip

我正在使用paperclip和paperclip-av-transcoder保存视频并在保存时为其创建缩略图。回形针模型如下。

class NewsAssets::Video < NewsAssets::Base

  has_attached_file :attachment,:styles => {
    :thumb => { :geometry => "100x100#", :format => 'jpg', :time => 10 },:medium => {:geometry => "640x480", :format => 'mp4' }
    }, :processors => [:transcoder],
    :path => (Rails.env.development? ? "#{Rails.root}/public/sys_path/:styles/:basename.:extension" : "public/sys_path/:styles/:basename.:extension"),
    :url => (Rails.env.development? ? "/sys_path/:styles/:basename.:extension" : ':s3_alias_url'),
    :storage => (Rails.env.development? ? :filesystem : :s3),
    :s3_permissions => 'public_read'
end

保存视频缩略图后,在文件夹内创建为jpg图像。

public/sys_path/thumbs/file.jpg

但无法检索它。我正在使用rails-4。是否有任何书写方式或方法来检索拇指?

1 个答案:

答案 0 :(得分:1)

这对我有用。

array([[    0.        ,     0.        ,     0.        , ...,
        0.        ,     0.        ,     0.        ],
   [   34.19227552,    34.19246389,    34.19265956, ...,
       34.19284295,    34.19253446,    34.1923012 ],
   [   68.46819899,    68.46861825,    68.46892983, ...,
       68.46895204,    68.46856004,    68.46812476],
   ..., 
   [ 3937.42832088,  3937.42522049,  3937.43673897, ...,
     3937.43603929,  3937.44434961,  3937.43535423],
   [ 3987.08591207,  3987.082997  ,  3987.09487184, ...,
     3987.09300137,  3987.10157045,  3987.09271431],
   [ 4037.00035477,  4036.9977684 ,  4037.01006508, ...,
     4037.00674248,  4037.01561165,  4037.00689316]])

而我的模型有

   <%@videos.each do |v|
      <p><%= image_tag(v.vid.url(:thumb)) %></p>
    <% end %>