Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ruby-on-rails/54.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby on rails 带有carrierwave视频缩略图器的ffmpegthumbnailer错误_Ruby On Rails_Ffmpeg_Thumbnails_Carrierwave - Fatal编程技术网

Ruby on rails 带有carrierwave视频缩略图器的ffmpegthumbnailer错误

Ruby on rails 带有carrierwave视频缩略图器的ffmpegthumbnailer错误,ruby-on-rails,ffmpeg,thumbnails,carrierwave,Ruby On Rails,Ffmpeg,Thumbnails,Carrierwave,当我尝试使用运行ffmpegthumbnailer时,会出现错误“没有这样的文件或目录” 我确认ffmpegthumbnailer在我的计算机上工作正常,因为我可以直接从命令行从视频生成缩略图 从我的日志来看,我的应用程序似乎认为它生成了一个缩略图。但是,当我查看目录时,没有文件tmpfile.png,我的应用程序失败并出现错误 是否有人成功使用CarrierWave视频缩略图程序gem创建缩略图,如果是,我做错了什么?或者,如果有某种方法可以在我的模型中运行ffmpegthumbnailer,

当我尝试使用运行ffmpegthumbnailer时,会出现错误“没有这样的文件或目录”

我确认ffmpegthumbnailer在我的计算机上工作正常,因为我可以直接从命令行从视频生成缩略图

从我的日志来看,我的应用程序似乎认为它生成了一个缩略图。但是,当我查看目录时,没有文件tmpfile.png,我的应用程序失败并出现错误

是否有人成功使用CarrierWave视频缩略图程序gem创建缩略图,如果是,我做错了什么?或者,如果有某种方法可以在我的模型中运行ffmpegthumbnailer,我也可以这样做

这是我的日志:

Running....ffmpegthumbnailer -i /Users/.../Website/public/uploads/tmp/1380315873-21590-2814/thumb_Untitled.mov -o /Users/.../Website/public/uploads/tmp/1380315873-21590-2814/tmpfile.png -c png -q 10 -s 192 -f
Success!
Errno::ENOENT: No such file or directory - (/Users/.../Website/public/uploads/tmp/1380315873-21590-2814/tmpfile.png, /Users/.../Website/public/uploads/tmp/1380315873-21590-2814/thumb_Untitled.mov)
视频路径上传器.rb

class VideoPathUploader < CarrierWave::Uploader::Base
  include CarrierWave::Video
  include CarrierWave::Video::Thumbnailer

  process encode_video: [:mp4]

  # Include RMagick or MiniMagick support:
  # include CarrierWave::RMagick
  include CarrierWave::MiniMagick

  # Choose what kind of storage to use for this uploader:
  # storage :file
  storage :fog

  # 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
    "#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}"
  end

   version :thumb do
      process thumbnail: [{format: 'png', quality: 10, size: 192, strip: true, logger: Rails.logger}]
      def full_filename for_file
        png_name for_file, version_name
      end
  end

    def png_name for_file, version_name
      %Q{#{version_name}_#{for_file.chomp(File.extname(for_file))}.png}
    end

end
class Video < ActiveRecord::Base
  # maybe we should add a title attribute to the video?
  attr_accessible :position, :project_id, :step_id, :image_id, :saved, :embed_url, :thumbnail_url, :video_path
  mount_uploader :video_path, VideoPathUploader
...
end
class VideoPathUploader
Video.rb

class VideoPathUploader < CarrierWave::Uploader::Base
  include CarrierWave::Video
  include CarrierWave::Video::Thumbnailer

  process encode_video: [:mp4]

  # Include RMagick or MiniMagick support:
  # include CarrierWave::RMagick
  include CarrierWave::MiniMagick

  # Choose what kind of storage to use for this uploader:
  # storage :file
  storage :fog

  # 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
    "#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}"
  end

   version :thumb do
      process thumbnail: [{format: 'png', quality: 10, size: 192, strip: true, logger: Rails.logger}]
      def full_filename for_file
        png_name for_file, version_name
      end
  end

    def png_name for_file, version_name
      %Q{#{version_name}_#{for_file.chomp(File.extname(for_file))}.png}
    end

end
class Video < ActiveRecord::Base
  # maybe we should add a title attribute to the video?
  attr_accessible :position, :project_id, :step_id, :image_id, :saved, :embed_url, :thumbnail_url, :video_path
  mount_uploader :video_path, VideoPathUploader
...
end
class-Video
我收到了与您相同的错误。事实证明,当gem试图运行ffmpegthumbnailer命令时,它失败了,因为输入和输出文件路径包含空格

我用叉子叉起宝石并改变:

cmd = %Q{#{CarrierWave::Video::Thumbnailer::FFMpegThumbnailer.binary} -i #{input_path} -o #{output_path} #{options.to_cli}}.rstrip

在文件中:

lib/carrierwave/video/thumbnailer/ffmpegthumbnailer.rb
i、 我用双引号括住了“输入路径”和“输出路径”参数

这为我解决了这个问题,并且成功地在原始电影文件所在的同一目录中生成了png缩略图。作为参考,我正在为使用多部分表单上传的.mov quicktime文件生成缩略图


我使用的是carrierwave-video-thumbnailer-0.1.4

谢谢-这是您建议的间距问题!