0

Carrierwave-video-thumbnailer gemを使用して ffmpegthumbnailer を実行しようとすると、「そのようなファイルまたはディレクトリはありません」というエラーが表示されます。

コマンドラインから直接ビデオからサムネイル画像を生成できるため、ffmpegthumbnailer が私のコンピューターで正しく動作することを確認しました。

私のログから、私のアプリはサムネイル画像を生成したと考えているようです。しかし、ディレクトリを見ると、ファイル tmpfile.png がなく、アプリがエラーで失敗します。

Carrierewave-video-thumbnailer ジェムを使用してサムネイルを作成した人はいますか?もしそうなら、何が間違っていますか? あるいは、モデル内で 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)

video_path_uploader.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

ビデオ.rb

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
4

1 に答える 1

1

私はあなたと同じエラーを受け取っていました。gem がffmpegthumbnailerコマンドを実行しようとしたときに、入力ファイルと出力ファイルのパスにスペースが含まれていたため、失敗していたことが判明しました。

宝石をフォークして変更することでこれを修正しました:

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

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

ファイル内:

lib/carrierwave/video/thumbnailer/ffmpegthumbnailer.rb

つまり、'input_path' および 'output_path' 引数を二重引用符で囲みました。

これで問題が解決し、元のムービー ファイルと同じディレクトリに png サムネイルが正常に生成されました。参考までに、マルチパート フォームを使用してアップロードされた .mov クイックタイム ファイルのサムネイル画像を生成していました。

私はcarrierwave-video-thumbnailer-0.1.4を使用していました

于 2014-01-30T15:12:14.170 に答える