Below are the steps I took to install ffmpeg, ffmpegthumbnailer, and heroku to use with carrierwave-video and carrierwave-video-thumbnailer gems on my heroku app. I found there was no documentation to do exactly this, so I hope this is helpful for other people (and will save them the countless hours it took me to finally get it to work)
- carrierwave-video gem: https://github.com/rheaton/carrierwave-video
- carrierwave-video-thumbnailer gem: https://github.com/evrone/carrierwave-video-thumbnailer
These are the libraries you will end up installing to get all of this to work.
- x264
- libvorbis
- libvpx
- faac
- libogg
- Setting up Vulcan
You will first create a build server using the Vulcan gem. Vulcan will automatically try to use the Heroku Cloudant add-on, which is only possible if you have a credit card associated with your Heroku account (what you will be doing will not cost anything, though, so don't worry about your credit card being charged).
Add your credit card to your Heroku account by going to https://dashboard.heroku.com/account and adding your credit card under "Billing"
Add cloudant add on (type this in your console)
heroku addons:add cloudant:oxygen
Install the vulcan gem
gem install vulcan
Create your app (replace foo with whatever you want to name your app)
vulcan create foo
Clone the app you just created
git clone [email protected]/foo.git
- Compile FAAC
Download and extract the following tar:
http://downloads.sourceforge.net/faac/faac-1.28.tar.bz2
Remove line 126 of common/mp4v2/mpeg4ip.h (containing strcasestr) (more information about why here: http://stackoverflow.com/questions/4320226/installing-faac-on-linux-getting-errors)
cd to your faac-1.28 directory and run the following command:
vulcan build -v -s . -c "./configure --enable-shared --disable-asm --prefix=/app/vendor/libfaac && make && make install"
After it builds successfully, you should get something like this:
# >> Downloading build artifacts to: /tmp/.../.tgz
# (available at http://foo.herokuapp.com/output/...)
Go to the link and download the .tgz file, extract it, and create the directory vendor/libfaac in your local app directory. Drop the contents of the .tgz into this folder.
Push your added files to Heroku
heroku add .
heroku commit -m "added faac"
heroku push
- Compile libvpx
Download and extract the following tar:
http://webm.googlecode.com/files/libvpx-v1.2.0.tar.bz2
cd to your libvpx directory and run the following command (the atoms-vulcan dependency is added because libvpx requires yasm, which is provided by the link)
vulcan build -v -s . -d 'http://atmos-vulcan.herokuapp.com/output/e1230abc-1f1f-40ab-8354-216269c0498a' -c "./configure --enable-shared --disable-static --as=auto --prefix=/app/vendor/llibvpx && make && make install”
As before, download the .tgz after it finishes, extract it, and put it into a folder vendor/libvpx.
Add and push to Heroku
- Get x264, libogg, and libvorbis
Download all those libraries here:
-
x264: http://atmos-vulcan.herokuapp.com/output/071eb00f-6667-4c42-8ebf-3926aec762e1
-
libogg: http://atmos-vulcan.herokuapp.com/output/128cbd68-ddc3-4888-8bdf-f93c1dcb8ea1
-
libvorbis: http://atmos-vulcan.herokuapp.com/output/69621463-23c7-4062-9f59-19086677fc5a
Create directories for each in your vendor folder (vendor/x264, vendor/libogg, vendor/libvorbis) and put the extracted contents into the appropriate folders
Add and push to Heroku
- Build ffmpeg
Get the ffmpeg source and cd to ffmpeg:
git clone --depth 1 git://source.ffmpeg.org/ffmpeg
Build ffmpeg with the following command (the extra links provide the necessary dependencies libvpx, libvorbis, libogg, and x264 pre-compiled):
vulcan build -v -c 'mkdir -p /app/vendor/ffmpeg && ./configure --prefix=/app/vendor/ffmpeg --extra-cflags='-I/app/vendor/libfaac/include' --extra-ldflags='-L/app/vendor/libfaac/lib' --enable-gpl --enable-nonfree --enable-libvorbis --enable-libfaac --enable-libx264 --enable-libvpx && make && make install' -n ffmpeg -d http://atmos-vulcan.herokuapp.com/output/016022b6-2fb3-4fe4-b595-2291832a0b53 http://atmos-vulcan.herokuapp.com/output/e1230abc-1f1f-40ab-8354-216269c0498a http://atmos-vulcan.herokuapp.com/output/071eb00f-6667-4c42-8ebf-3926aec762e1 http://atmos-vulcan.herokuapp.com/output/128cbd68-ddc3-4888-8bdf-f93c1dcb8ea1 http://atmos-vulcan.herokuapp.com/output/69621463-23c7-4062-9f59-19086677fc5a http://atmos-vulcan.herokuapp.com/output/2caa3cd5-942a-4ece-bfb9-b56e14dd0fc0 http://atmos-vulcan.herokuapp.com/output/38a531b8-3898-4890-b773-2c48bcd26820
This should take a while (it took around 15 minutes for me). When it's done, download the files and put it into vendor/ffmpeg.
Add and push to Heroku
- Build ffmpegthumbnailer
Get the source and cd into ffmpegthumbnailer-2.0.8:
wget http://ffmpegthumbnailer.googlecode.com/files/ffmpegthumbnailer-2.0.8.tar.gz
Build ffmpegthumbnailer with the following command
vulcan build -v -s . -c "./configure --prefix=/app/vendor/ffmpegthumbnailer --enable-png --enable-jpeg --enable-static --with-pic PKG_CONFIG_PATH=/app/vendor/ffmpeg/lib/pkgconfig/"
Download the .tgz and put it into vendor/ffmpegthumbnailer
I found that my install of ffmpeg was missing some files that I was able to get here:
https://github.com/JonasNielsen/ffmpegthumbnailer/blob/master/
Download this and copy the contents of vendor/ffmpeg/lib into the ffmpeg/lib folder. In particular, I was missing some files with a .so extension.
After all these additions, add your changes and push to heroku.
- Add ffmpeg and ffmpegthumbnailer to your actual heroku app
Now take your compiled vendor/ffmpeg and vendor/ffmpegthumbnailer folders from your foo directory and put them into your actual heroku app.
After adding, push to heorku for your actual app.
Configure the PATH for your heroku app:
heroku config:set PATH=bin:vendor/libfaac/bin:vendor/x264/bin:vendor/libvpx/bin:vendor/ffmpeg/bin:vendor/ffmpegthumbnailer/bin:vendor/bundle/ruby/1.9.1/bin:/usr/local/bin:/usr/bin:/bin
Configure the LD_LIBRARY_PATH for your app:
heroku config:set LD_LIBRARY_PATH=vendor/libfaac/lib:vendor/libvpx/lib:vendor/ffmpeg/lib:vendor/x264/lib:vendor/ffmpegthumbnailer/lib:/usr/local/lib
Everything should magically work at this point!
These are some things I found valuable for troubleshooting:
You can check the config settings of your Heroku app with:
heroku config -a *your_app_name*
You can check if things are set up correctly by running:
heroku run which *library* -a *your_app_name*
(for example, heroku run which ffmpeg -a foo)
You can check the contents on heroku with:
heroku run bash -a *your_app_name*
GOOD LUCK!
By any chance can anyone provide static build of this? Cloudant addon doesn't seem to work at this moment.
I've tried to upload compiled version pulled from some other repository(https://github.com/JonasNielsen/ffmpegthumbnailer), but it didn't work well with carrierwave-video.