2013-09-27 77 views
0

當我嘗試使用carrierwave-video-thumbnailer gem運行ffmpegthumbnailer時,出現錯誤「No such file or directory」。ffmpegthumbnailer error with carrierwave-video-thumbnailer

我確認ffmpegthumbnailer在我的電腦上正常工作,因爲我可以直接從命令行直接從視頻生成縮略圖。

從我的日誌中,它看起來像我的應用程序認爲它已生成縮略圖圖像。但是,當我查看目錄時,沒有文件tmpfile.png,並且我的應用程序因錯誤而失敗。

有沒有人成功地使用carrierewave-video-thumbnailer 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) 

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 

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

回答

1

我收到了同樣的錯誤,你。事實證明,當寶石試圖運行命令時,它失敗了,因爲輸入和輸出文件路徑包含空格。

我固定這通過分叉的寶石和改變:

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 quicktime文件生成縮略圖。

我用carrierwave - 視頻 - thumbnailer的-0.1.4

+0

感謝 - 這是與間距的問題,因爲你的建議! – scientiffic