我正在使用carrierwave上传视频,然后有一个名为thumb的版本,带有一个自定义处理器,可以获取视频并使用streamio-ffmpeg创建屏幕截图。视频和文件均已正确上传,但是在调用 uploader.url(:thumb) 时,我得到:
ArgumentError:版本拇指不存在!
视频上传器.rb
require 'carrierwave/processing/mime_types'
require 'streamio-ffmpeg'
class VideoUploader < CarrierWave::Uploader::Base
include CarrierWave::VideoConverter
include CarrierWave::MimeTypes
process :set_content_type
storage :file
version :thumb do
process :create_thumb
#def full_filename(for_file)
# "thumb_#{File.basename(for_file, File.extname(for_file))}.png"
#end
end
def create_thumb
cached_stored_file! if !cached?
movie = FFMPEG::Movie.new(current_path)
dirname = File.dirname(current_path)
thumb_path = "#{File.join(dirname, File.basename(path, File.extname(path)))}.png"
movie.screenshot(thumb_path, :seek_time => 5)
File.rename thumb_path, current_path
end
def file_identifier
model[:video]
end
# Override the directory where uploaded files will be stored.
# This is a sensible default for uploaders that are meant to be mounted:
def store_dir
return "uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.user_id}/#{model.id}"
end
end
然后 model.video_url(:thumb) 返回参数错误。我不知道该怎么做或为什么版本没有注册任何帮助会很好,谢谢。