我正在尝试使用 Voyeur gem 将视频从 .mp4 转换为 .webm 然后上传。这是我的代码:app/uploads/video_uploader.rb
class VideoUploader < CarrierWave::Uploader::Base
include CarrierWave::VideoConverter
def store_dir
"uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}"
end
version :mp4 do
process :encode_video => [:mp4]
def full_filename(for_file)
"#{File.basename(for_file, File.extname(for_file))}.mp4"
end
end
version :webm do
process :encode_video => [:webm]
def full_filename(for_file)
"#{File.basename(for_file, File.extname(for_file))}.webm"
end
end
end
video_converter.rb 模块已放置在 /lib/carrierwave/processing/
autoload :VideoConverter, 'carrierwave/processing/video_converter'
已添加到 /lib/carrierwave.rb
我的模型:
class Uploader < ActiveRecord::Base
require 'Voyeur'
attr_accessible :user_id,:attach_file
belongs_to :user
mount_uploader :attach_file, VideoUploader
end
但是我不能上传视频,控制台报错:
Errno::ENOENT: No such file or directory - ffmpeg -i /home/------/______/public/uploads/tmp/20121211-0943-7368-8271/tmpfile
有什么建议吗?
我在控制台中使用的最简单的命令:Voyeur::Media.new( filename: path_to_file ).convert( to: :mp4 )
仍然失败并出现类似错误。