2013-04-17 55 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