2013-04-17 87 views
0

我試圖拍攝上傳視頻的快照。 以下回形針處理器在我的本地環境中正常工作,但在Heroku中失敗。帶回形針的視頻縮略圖+ ImageMagick + Heroku

module Paperclip 
    class VideoThumbnail < Processor 

    require 'RMagick' 
    attr_accessor :current_geometry, :target_geometry, :format, :whiny, :convert_options, :source_file_options 

    def initialize file, options = {}, attachment = nil 
     super 
     @file    = file 
     @format_op    = options[:format] 
     @format = File.extname(@file.path) 
     @basename = File.basename(@file.path, @format) 
    end 


    def make 
     src = @file 
     dst = Tempfile.new([@basename, ".png"]) 
     dst.binmode 
     parameters = [] 
     parameters << "-quiet" 
     parameters << ":source" 
     parameters << ":dest" 
     parameters = parameters.flatten.compact.join(" ").strip.squeeze(" ") 

     success = Paperclip.run("convert", parameters, :source => "#{File.expand_path(file.path)}[1]", :dest => File.expand_path(dst.path)) 

     dst 
    end 
    end 
end 

的錯誤是:

2013-04-17T18:25:20.781972+00:00 heroku[router]: at=info method=POST path=/admin/content_items host=mclauncher.herokuapp.com fwd="186.55.107.205" dyno=web.1 connect=1ms service=12253ms status=500 bytes=643 
2013-04-17T18:25:20.774386+00:00 app[web.1]: convert: Delegate failed `"ffmpeg" -v -1 -vframes %S -i "%i" -vcodec pam -an -f rawvideo -y "%u.pam" 2> "%Z"' @ delegate.c/InvokeDelegate/1060. 
2013-04-17T18:25:20.779544+00:00 app[web.1]: 
2013-04-17T18:25:20.774386+00:00 app[web.1]: convert: missing an image filename `/tmp/Valves20130417-2-170vly120130417-2-78zghs.png' @ convert.c/ConvertImageCommand/2838. 
2013-04-17T18:25:20.774386+00:00 app[web.1]: convert: unable to open image `/tmp/magick-XXqompcz.pam': No such file or directory @ blob.c/OpenBlob/2480. 
2013-04-17T18:25:20.779544+00:00 app[web.1]: 
2013-04-17T18:25:20.779544+00:00 app[web.1]: 
2013-04-17T18:25:20.780154+00:00 app[web.1]: Processing by Admin::ContentItemsController#create as HTML 
2013-04-17T18:25:20.779544+00:00 app[web.1]: lib/paperclip_processors/video_thumbnail.rb:47:in `make' 
2013-04-17T18:25:20.779544+00:00 app[web.1]:): 
2013-04-17T18:25:20.780154+00:00 app[web.1]: Command :: convert -quiet '/tmp/Valves20130417-2-170vly1.mp4[1]' '/tmp/Valves20130417-2-170vly120130417-2-78zghs.png' 
2013-04-17T18:25:20.779544+00:00 app[web.1]: 
2013-04-17T18:25:20.779544+00:00 app[web.1]: Cocaine::ExitStatusError (Command 'convert -quiet '/tmp/Valves20130417-2-170vly1.mp4[1]' '/tmp/Valves20130417-2-170vly120130417-2-78zghs.png'' returned 1. Expected 0 
2013-04-17T18:25:20.779544+00:00 app[web.1]: Here is the command output: 
2013-04-17T18:25:20.780154+00:00 app[web.1]: Parameters: {"utf8"=>"✓", "authenticity_token"=>"F5Y3tflzqvUlDbaOPBDiYHwUTGIVpoMaUIXL/QQfkbg=", "content_item"=>{"content_group_id"=>"3", "name"=>"asd", "emailable"=>"", "app_launch_url"=>"", "app_install_url"=>"", "file_item"=>#<ActionDispatch::Http::UploadedFile:0x000000061d2878 @original_filename="Valves.mp4", @content_type="video/mp4", @headers="Content-Disposition: form-data; name=\"content_item[file_item]\"; filename=\"Valves.mp4\"\r\nContent-Type: video/mp4\r\n", @tempfile=#<File:/tmp/RackMultipart20130417-2-1wvc61m>>}, "commit"=>"Create Content item"} 

任何幫助嗎?

+0

您使用的是什麼版本的'RMagick'?難道你只用一個dyno來使用heroku,這意味着你的空間有限,所以新的圖像根本無法在heroku磁盤上分配? – gmile

+0

RMagick 2.12.0。我正在使用1 dyno。我嘗試了2個dynos並得到了相同的問題 – Tony

回答

0

我可能會錯過一些東西,但它看起來像heroku有一個只讀的磁盤存儲。看看this。相反,使用S3上傳是存儲文件的一種優先方式。他們也有關於這個問題的article

+0

正如您在鏈接中看到的那樣。有兩個可寫的目錄:./tmp和./log。它使用/ tmp – Tony