Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/ruby-on-rails-4/2.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/heroku/2.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 4 Ruby on Rails 4 Heroku应用程序在上载大尺寸视频时崩溃_Ruby On Rails 4_Heroku_Amazon S3_Ffmpeg_Paperclip - Fatal编程技术网

Ruby on rails 4 Ruby on Rails 4 Heroku应用程序在上载大尺寸视频时崩溃

Ruby on rails 4 Ruby on Rails 4 Heroku应用程序在上载大尺寸视频时崩溃,ruby-on-rails-4,heroku,amazon-s3,ffmpeg,paperclip,Ruby On Rails 4,Heroku,Amazon S3,Ffmpeg,Paperclip,大型视频文件未上载到heroku上,并引发应用程序崩溃错误 这是我的型号代码: has_attached_file :video, :styles => { :medium => { :geometry => "640x480", :format => 'mp4', :convert_options => { :output => { :vcodec => 'libx264', :acodec

大型视频文件未上载到heroku上,并引发应用程序崩溃错误
这是我的型号代码:

has_attached_file :video, :styles => {
  :medium => {
    :geometry => "640x480",
    :format => 'mp4',
    :convert_options => {
    :output => {
      :vcodec => 'libx264',
      :acodec => 'copy'
    }
  }
  },
  :thumb => {
    :geometry => "300x300#",
    :format => 'jpg',
    :time => 2,
    :auto_rotate => true
  }
}, :processors => [:transcoder]

validates_attachment_content_type :video, content_type: /\Avideo\/.*\Z/
这是我在heroku的日志

2016-07-22T13:15:13.616340+00:00 app[web.1]: Command :: file -b --mime '/tmp/33028ec79c8028f75908c90d9f018aeb20160722-3-1e90wvf.mp4'
2016-07-22T13:15:13.771935+00:00 app[web.1]: [AV] Running command: if command -v avprobe 2>/dev/null; then echo "true"; else echo "false"; fi
2016-07-22T13:15:13.773078+00:00 app[web.1]: [AV] Running command: if command -v ffmpeg 2>/dev/null; then echo "true"; else echo "false"; fi
2016-07-22T13:15:13.774121+00:00 app[web.1]: [AV] Found ["ffmpeg"], using: Ffmpeg
2016-07-22T13:15:13.774159+00:00 app[web.1]: [AV] Running command: if command -v avprobe 2>/dev/null; then echo "true"; else echo "false"; fi
2016-07-22T13:15:13.775225+00:00 app[web.1]: [AV] Running command: if command -v ffmpeg 2>/dev/null; then echo "true"; else echo "false"; fi
2016-07-22T13:15:13.776771+00:00 app[web.1]: [AV] Found ["ffmpeg"], using: Ffmpeg
2016-07-22T13:15:13.776807+00:00 app[web.1]: [AV] Running command: ffmpeg -i "/tmp/33028ec79c8028f75908c90d9f018aeb20160722-3-xbemwt.mp4" 2>&1
2016-07-22T13:15:13.814982+00:00 app[web.1]: [paperclip] [transcoder] Transocding supported file /tmp/33028ec79c8028f75908c90d9f018aeb20160722-3-xbemwt.mp4
2016-07-22T13:15:13.815056+00:00 app[web.1]: [AV] Adding output parameter ["acodec", "aac"]
2016-07-22T13:15:13.815103+00:00 app[web.1]: [AV] Adding output parameter ["strict", "experimental"]
2016-07-22T13:15:13.815289+00:00 app[web.1]: [AV] Adding output parameter [:s, "640x480"]
2016-07-22T13:15:13.815379+00:00 app[web.1]: [AV] Running command: ffmpeg -i "/tmp/33028ec79c8028f75908c90d9f018aeb20160722-3-xbemwt.mp4" -acodec aac -strict experimental -s 640x480 -y "/tmp/33028ec79c8028f75908c90d9f018aeb20160722-3-xbemwt20160722-3-1pwdg2k.mp4"
2016-07-22T13:15:43.237749+00:00 heroku[router]: at=error code=H12 desc="Request timeout" method=POST path="/courses/5/sections/7/lessons/11" host=xxxxx.herokuapp.com request_id=a1408ac7-c7c3-40f4-8365-86156d2d2314 fwd="43.255.56.1" dyno=web.1 connect=0ms service=188655ms status=503 bytes=0

显然是请求超时。检查他们建议如何处理请求超时

当HTTP请求需要很长时间才能响应用户时,会发生请求超时。服务器,或者在本例中,处理请求的heorku路由器,如果在设定的超时时间内没有响应,将终止请求

这可能是因为文件太大,上传或处理它需要更多的时间。我建议您直接从Javascript上传到S3,或者使用后台工作人员来完成这项工作。这意味着,您需要重新说明如何向用户提供上载功能


如果您有Stacktrace和heroku日志中的异常消息,那么检查从用户浏览器直接上传到S3将非常有用。@SriVishnuTotakura我已经在问题描述中粘贴了我的日志信息,您是说直接将大文件上传到S3。但我还需要使用ffmpeg转码器生成缩略图。那么ffmpeg呢?那么您必须首先直接从浏览器上传到S3。保存到S3后,再生成缩略图。如果这需要相当长的时间,请使用一些后台工作人员拾取最近保存的视频,在后台处理它们,并使用一些回调向用户显示状态。