Skip to content

Instantly share code, notes, and snippets.

@coopermaruyama
Created October 27, 2012 08:39
Show Gist options
  • Save coopermaruyama/3963576 to your computer and use it in GitHub Desktop.
Save coopermaruyama/3963576 to your computer and use it in GitHub Desktop.
Install FFMpeg on heroku (Rails)
## Get FFMpeg working on heroku by building binaries using vulcan
gem install vulcan
vulcan create foo
git clone --depth 1 git://source.ffmpeg.org/ffmpeg
cd ffmpeg
vulcan build -v -s . -c "./configure --enable-shared --disable-asm --prefix=/app/vendor/ffmpeg && make && make install"
## once done, you'll see something along the lines of:
# >> Downloading build artifacts to: /tmp/ffmpeg.tgz
# (available at http://foo.herokuapp.com/output/d21f6bb8-6db6-4397-b02e-347806945881)
#
# Download the .tgz via the link or cd to /tmp then:
tar xvf ffmpeg.tgz
mkdir /path/to/app/vendor/ffmpeg
mv ffmpeg/* /path/to/app/vendor/ffmpeg/
# cd to your app then:
heroku config:set PATH=bin:vendor/ffmpeg/bin:vendor/bundle/ruby/1.9.1/bin:/usr/local/bin:/usr/bin:/bin -a yourapp
#in the above, make sure you are simply appending 'vendor/ffmpeg/bin' to whatever is already set when you run 'heroku config' and look at the currently set value for PATH. overwriting it will break your app.
heroku config:set LD_LIBRARY_PATH=vendor/ffmpeg/lib:/usr/local/lib -a yourapp
git add .
git commit -m "vendor ffmpeg"
git push heroku master
# enjoy!
@joshed-io
Copy link

This worked for me, thank you. Quick question - I noticed that the resulting ffmpeg directory is quite large at 146Mb, mostly in ffmpeg/lib (144Mb). It still fits into a dyno but the dyno ends up about around 90Mb. Any thoughts on if it's possible to slim this down?

@n0phx
Copy link

n0phx commented Dec 11, 2012

License: LGPL version 2.1 or later
Creating config.mak and config.h...
/usr/local/lib/ruby/1.9.1/cgi/util.rb:7:in `escape': undefined method `gsub' for nil:NilClass (NoMethodError)
    from /app/vendor/gems/gems/couchrest-1.1.2/lib/couchrest/database.rb:375:in `escape_docid'
    from /app/vendor/gems/gems/couchrest-1.1.2/lib/couchrest/database.rb:80:in `get'
    from /app/bin/make:19:in `block (2 levels) in <main>'
    from /app/bin/make:18:in `chdir'
    from /app/bin/make:18:in `block in <main>'
    from /usr/local/lib/ruby/1.9.1/tmpdir.rb:83:in `mktmpdir'
    from /app/bin/make:17:in `<main>'
bin/make:66:in `chdir': No such file or directory - /ffmpegbuild/vendor/ffmpeg (Errno::ENOENT)
    from bin/make:66:in `block (2 levels) in <main>'
    from bin/make:18:in `chdir'
    from bin/make:18:in `block in <main>'
    from /usr/local/lib/ruby/1.9.1/tmpdir.rb:83:in `mktmpdir'
    from bin/make:17:in `<main>'
>> Downloading build artifacts to: /tmp/ffmpeg.tgz
   (available at http://ffmpegbuild.herokuapp.com/output/4e55cb41-433f-4b38-a72c-e2f8d62f8bd2)

Any thoughts why did I get this? Thanks

@RyanFriedman
Copy link

This worked for me as well! Thanks Cooper.

Any idea how to get this working with libmp3lame and libfaac and/or other codecs?

@liufengyun
Copy link

Thanks @coopermaruyama for sharing this gist. I've setup http://wave.herokuapp.com/ on heroku, it works great.

BTW, @dzello, to make it slim, remove all static lib(*.a) in vendor/ffmpeg/lib folder, it will reduce to about 10M.

@shem8
Copy link

shem8 commented May 22, 2013

If you don'e need to compile you can just use the already compiled static library from ffmpeg download page,
more about this here:
http://pastebin.com/8SAvbdjU

@koko37
Copy link

koko37 commented Oct 9, 2013

and is there ffmpegthumbnailer, already built?

@coopermaruyama
Copy link
Author

Sorry guys, I never received any notifications about your comments, I had no idea till now that you guys all commented. Since the most recent comment was a year ago I'm hoping you guys all figured it out. If not, let me know and I'll do my best to answer.

When I created this I was trying to get ruby-audio working on heroku. If anyone else is here for the same reason, a buddy and I created a ruby gem that might help your efforts: https://github.com/khurramzaman/ruby-audio-heroku

@integricho your issue looks to have something to do with vulcan. you can ssh into it I think (check the docs) and try running the commands there and debug it there. There are plenty of other forks now as well that may be more reliable than mine.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment