简体   繁体   English

让 ffmpeg 与 Heroku 一起工作

[英]Getting ffmpeg to work with Heroku

I attempted to install ffmpeg for my Heroku Rails app and now my app is crashing.我试图为我的 Heroku Rails 应用程序安装 ffmpeg,现在我的应用程序崩溃了。

I added a buildpack using the following command:我使用以下命令添加了一个 buildpack:

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

After pushing to Heroku, I get the following error according to my logs:推送到 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=

When I run heroku run rake db:migrate , I get the error:当我运行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>'

When I check the version of bundler I'm using (bundle show bundler), I get:当我检查我正在使用的 bundler 版本(bundle show bundler)时,我得到:

/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

How can I solve this problem?我该如何解决这个问题?

You have replaced the Ruby buildpack with the FFMpeg buildpack.您已将 Ruby 构建包替换为 FFMpeg 构建包。 That doesn't work.那行不通。 You still need to include the Ruby buildpack to run a Rails app.您仍然需要包含 Ruby buildpack 才能运行 Rails 应用程序。

You can do this by using ddollar's heroku buildpack-multi - https://github.com/ddollar/heroku-buildpack-multi您可以使用 ddollar 的 heroku buildpack-multi 来做到这一点 - https://github.com/ddollar/heroku-buildpack-multi

You would then add a .buildpacks file to the root directory of your project that includes both the standard Ruby buildpack and your FFMpeg buildpack.然后,您将一个 .buildpacks 文件添加到您的项目的根目录,其中包括标准的 Ruby 构建包和 FFMpeg 构建包。

I had a similar issue when I tried to install FFMPEG with my rails app onto Heroku.当我尝试将 FFMPEG 与我的 rails 应用程序安装到 Heroku 上时,我遇到了类似的问题。 I ended up using paperclip-av-transcoder gem, because all the other FFMPEG gems had been deprecated.我最终使用了 paperclip-av-transcoder gem,因为所有其他 FFMPEG gem 都已被弃用。

Regardless, I had install the FFMPEG buildpack on Heroku (an add-on element).无论如何,我已经在 Heroku(一个附加元素)上安装了 FFMPEG buildpack。 This killed my Heroku app processes, with "No web processes running" error.这杀死了我的 Heroku 应用程序进程,并出现“没有运行 Web 进程”错误。

Apparently, when you install a buildpack in Heroku you now have to create a Procfile with basic instructions like below:显然,当您在 Heroku 中安装 buildpack 时,您现在必须使用如下基本说明创建Procfile

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

However, you still have to log on to Heroku.com and turn them on!但是,您仍然需要登录 Heroku.com 并打开它们! Which is ridiculous!这是荒谬的! But my app works now.但我的应用程序现在可以工作了。

So the process is:所以过程是:

  1. Install gem安装 gem
  2. Install buildpack on Heroku在 Heroku 上安装 buildpack
  3. Create Procfile at your app's root path and write your basic instructions to launch the app and start dynos在应用程序的根路径创建 Procfile 并编写启动应用程序和启动 dynos 的基本说明
  4. Log onto Heroku.com and manually turn on the processes in your Resources tab.登录 Heroku.com 并手动打开“资源”选项卡中的进程。

If somebody is still having this issue in 2020, here is the solution: In order to make it FFmpeg work on Rails app on Heroku just run this from the Heroku CLI:如果有人在 2020 年仍然遇到这个问题,这里是解决方案:为了使其 FFmpeg 在 Heroku 上的 Rails 应用程序上工作,只需从 Heroku CLI 运行它:

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

I assume you're using Active storage for images/videos, so installing FFmpeg on Heroku will allow creating thumbnails for videos.我假设您对图像/视频使用主动存储,因此在 Heroku 上安装 FFmpeg 将允许为视频创建缩略图。 Link to Heroku documentation: https://devcenter.heroku.com/articles/active-storage-on-heroku Heroku 文档链接: https : //devcenter.heroku.com/articles/active-storage-on-heroku

I faced same issue and try to install existing ffmpeg buildpacks like https://github.com/issueapp/heroku-buildpack-ffmpeg but all only support 'ffmpeg' single commend but we required whole support of 'ffmpeg' like it work on our local system after installation.我遇到了同样的问题并尝试安装现有的 ffmpeg 构建包,如https://github.com/issueapp/heroku-buildpack-ffmpeg但都只支持 'ffmpeg' 单一推荐但我们需要完全支持 'ffmpeg' 就像它在我们的工作安装后本地系统。

I have made some change in buildpack and created a custom build pack at https://github.com/laddhadhiraj/heroku-buildpack-ffmpeg so it will support all ffmpeg command 'ffmpeg, ffprobe, ffserver, ffmpeg-10bit and qt-faststart'我对 buildpack 进行了一些更改,并在https://github.com/laddhadhiraj/heroku-buildpack-ffmpeg创建了一个自定义构建包,因此它将支持所有 ffmpeg 命令 'ffmpeg、ffprobe、ffserver、ffmpeg-10bit 和 qt-faststart '

Easy way for installing complete support of 'ffmpeg' for heroku app为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"

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM