Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting ffmpeg to work with Heroku

I attempted to install ffmpeg for my Heroku Rails app and now my app is crashing.

I added a buildpack using the following command:

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:

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:

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:

/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?

like image 547
scientiffic Avatar asked Nov 17 '13 17:11

scientiffic


4 Answers

You have replaced the Ruby buildpack with the FFMpeg buildpack. That doesn't work. You still need to include the Ruby buildpack to run a Rails app.

You can do this by using ddollar's 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.

like image 60
Peter Goldstein Avatar answered Nov 18 '22 19:11

Peter Goldstein


I had a similar issue when I tried to install FFMPEG with my rails app onto Heroku. I ended up using paperclip-av-transcoder gem, because all the other FFMPEG gems had been deprecated.

Regardless, I had install the FFMPEG buildpack on Heroku (an add-on element). This killed my Heroku app processes, with "No web processes running" error.

Apparently, when you install a buildpack in Heroku you now have to create a Procfile with basic instructions like below:

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! Which is ridiculous! But my app works now.

So the process is:

  1. Install gem
  2. Install buildpack on Heroku
  3. Create Procfile at your app's root path and write your basic instructions to launch the app and start dynos
  4. Log onto Heroku.com and manually turn on the processes in your Resources tab.
like image 4
Nicolai Robles Avatar answered Nov 18 '22 18:11

Nicolai Robles


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:

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. Link to Heroku documentation: https://devcenter.heroku.com/articles/active-storage-on-heroku

like image 3
Ivan Stepanović Avatar answered Nov 18 '22 18:11

Ivan Stepanović


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.

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'

Easy way for installing complete support of 'ffmpeg' for heroku app

# 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"
like image 2
Dhiraj Avatar answered Nov 18 '22 20:11

Dhiraj