【问题标题】:Getting ffmpeg to work with Heroku让 ffmpeg 与 Heroku 一起工作
【发布时间】:2013-11-30 19:09:23
【问题描述】:

我尝试为我的 Heroku Rails 应用安装 ffmpeg,但现在我的应用崩溃了。

我使用以下命令添加了一个构建包:

heroku config:add BUILDPACK_URL=https://github.com/shunjikonishi/heroku-buildpack-ffmpeg

推送到 Heroku 后,根据我的日志,我收到以下错误:

2013-11-17T17:50:44.022351+00:00 heroku[web.1]: Starting process with command `bundle exec rails server -p 47171`
2013-11-17T17:50:46.295602+00:00 app[web.1]: bash: bundle: command not found
2013-11-17T17:50:47.589491+00:00 heroku[web.1]: Process exited with status 127
2013-11-17T17:50:47.597968+00:00 heroku[web.1]: State changed from starting to crashed
2013-11-17T17:50:48.620853+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path=/ (...) fwd="76.118.180.235" dyno= connect= service= status=503 bytes=
2013-11-17T17:50:48.847288+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path=/favicon.ico host=(...) fwd="76.118.180.235" dyno= connect= service= status=503 bytes=

当我运行 heroku run rake db:migrate 时,我收到错误:

Running `rake db:migrate` attached to terminal... up, run.9791
(in /app)
rake aborted!
no such file to load -- bundler/setup
<internal:lib/rubygems/custom_require>:29:in `require'
<internal:lib/rubygems/custom_require>:29:in `require'
/app/config/boot.rb:6:in `<top (required)>'
<internal:lib/rubygems/custom_require>:29:in `require'
<internal:lib/rubygems/custom_require>:29:in `require'
/app/config/application.rb:1:in `<top (required)>'
<internal:lib/rubygems/custom_require>:29:in `require'
<internal:lib/rubygems/custom_require>:29:in `require'
/app/Rakefile:5:in `<top (required)>'
/usr/local/lib/ruby/1.9.1/rake.rb:2373:in `load'
/usr/local/lib/ruby/1.9.1/rake.rb:2373:in `raw_load_rakefile'
/usr/local/lib/ruby/1.9.1/rake.rb:2007:in `block in load_rakefile'
/usr/local/lib/ruby/1.9.1/rake.rb:2058:in `standard_exception_handling'
/usr/local/lib/ruby/1.9.1/rake.rb:2006:in `load_rakefile'
/usr/local/lib/ruby/1.9.1/rake.rb:1991:in `run'
/usr/local/bin/rake:31:in `<main>'

当我检查我正在使用的捆绑器版本时(捆绑显示捆绑器),我得到:

/Users/(...).rvm/gems/ruby-1.9.3-p448/gems/bundler-1.3.5/lib/bundler.rb:284: warning: Insecure world writable dir /usr/local in PATH, mode 040777
/Users/(...)/.rvm/gems/ruby-1.9.3-p448/gems/bundler-1.3.5

我该如何解决这个问题?

【问题讨论】:

    标签: ruby-on-rails heroku ffmpeg bundler


    【解决方案1】:

    您已将 Ruby 构建包替换为 FFMpeg 构建包。那是行不通的。您仍然需要包含 Ruby buildpack 才能运行 Rails 应用程序。

    您可以使用 ddollar 的 heroku buildpack-multi - https://github.com/ddollar/heroku-buildpack-multi 来做到这一点

    然后,您将在项目的根目录中添加一个 .buildpacks 文件,其中包括标准 Ruby buildpack 和您的 FFMpeg buildpack。

    【讨论】:

    【解决方案2】:

    当我尝试将 FFMPEG 与我的 rails 应用程序安装到 Heroku 上时,我遇到了类似的问题。我最终使用了 paperclip-av-transcoder gem,因为所有其他 FFMPEG gem 已被弃用。

    无论如何,我已经在 Heroku(一个附加元素)上安装了 FFMPEG buildpack。这杀死了我的 Heroku 应用程序进程,出现“没有运行 Web 进程”错误。

    显然,当您在 Heroku 中安装 buildpack 时,您现在必须创建一个 Procfile,其基本说明如下:

    web: bin/rails server -p $PORT -e $RAILS_ENV
    worker: bundle exec rake jobs:work
    

    但是,您仍然需要登录 Heroku.com 并打开它们!这太荒谬了!但我的应用程序现在可以工作了。

    所以流程是:

    1. 安装 gem
    2. 在 Heroku 上安装 buildpack
    3. 在应用的根路径创建 Procfile 并编写启动应用和启动 dynos 的基本说明
    4. 登录 Heroku.com 并手动打开“资源”选项卡中的进程。

    【讨论】:

      【解决方案3】:

      如果有人在 2020 年仍然遇到此问题,则解决方案如下: 为了让 FFmpeg 在 Heroku 上的 Rails 应用程序上运行,只需从 Heroku CLI 运行它:

      heroku buildpacks:add -i 1 https://github.com/heroku/heroku-buildpack-activestorage-preview
      

      我假设您使用 Active storage 存储图像/视频,因此在 Heroku 上安装 FFmpeg 将允许为视频创建缩略图。 Heroku 文档链接:https://devcenter.heroku.com/articles/active-storage-on-heroku

      【讨论】:

        【解决方案4】:

        我遇到了同样的问题,并尝试安装现有的 ffmpeg 构建包,例如 https://github.com/issueapp/heroku-buildpack-ffmpeg,但都只支持“ffmpeg”单一推荐,但我们需要完全支持“ffmpeg”,就像它在安装后在我们的本地系统上工作一样。

        我对 buildpack 进行了一些更改,并在 https://github.com/laddhadhiraj/heroku-buildpack-ffmpeg 创建了一个自定义构建包,因此它将支持所有 ffmpeg 命令 'ffmpeg、ffprobe、ffserver、ffmpeg-10bit 和 qt-faststart'

        为 heroku 应用安装完全支持“ffmpeg”的简单方法

        # Ruby buildpack
        $ cat .buildpacks
        https://github.com/laddhadhiraj/heroku-buildpack-ffmpeg
        https://github.com/heroku/heroku-buildpack-ruby
        
        # for new project
        $ heroku create --buildpack https://github.com/ddollar/heroku-buildpack-multi
        
        # for existing project
        $ heroku buildpacks:set https://github.com/ddollar/heroku-buildpack-multi
        
        $ heroku config:set FFMPEG_BIN_URL="http://johnvansickle.com/ffmpeg/releases/ffmpeg-release-64bit-static.tar.xz"
        
        $ git push heroku master
        
        # verify and profit!
        $ heroku run "ffmpeg -version"
        $ heroku run "ffprobe -version"
        $ heroku run "ffserver -version"
        $ heroku run "ffmpeg-10bit -version"
        $ heroku run "qt-faststart -version"
        

        【讨论】:

          猜你喜欢
          • 2013-11-08
          • 1970-01-01
          • 1970-01-01
          • 2013-10-25
          • 1970-01-01
          • 2014-10-30
          • 2016-12-13
          • 2016-10-06
          • 2011-11-30
          相关资源
          最近更新 更多