【问题标题】:How to access a video thumbnail saved using paperclip and paperclip-av-transcoder如何访问使用回形针和回形针-av-转码器保存的视频缩略图
【发布时间】:2016-05-31 12:01:36
【问题描述】:

我正在使用回形针和回形针-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。有没有什么方法或方法可以找回拇指?

【问题讨论】:

    标签: ruby-on-rails paperclip


    【解决方案1】:

    这对我有用。

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

    而我的模型有

    has_attached_file :vid, :styles => {
        :mp4 => { :format => 'mp4', :convert_options => { :output => { :vcodec => 'libx264' } } } ,
        :thumb => { :geometry => "200x200#", :format => 'jpg', :time => 10 }
      }, :processors => [:ffmpeg]
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-11-10
      • 2012-04-07
      • 2013-06-25
      • 1970-01-01
      • 1970-01-01
      • 2014-08-13
      相关资源
      最近更新 更多