Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save exocode/6009744 to your computer and use it in GitHub Desktop.
Save exocode/6009744 to your computer and use it in GitHub Desktop.
more precise documentation added libavfilter for amerge, amix and co...
## Get FFMpeg working on heroku by building binaries using vulcan
# also added instructions on how to compile with libmp3lame and libx264
####################################
# INSTALL VULCAN if not done already
gem install vulcan
#################
# CREATE YOUR APP "Foo"
vulcan create foo
##################################
#Clone the VULCAN APP FOO just created
git clone git@heroku.com:foo
############
# x264 CODEX
# Clone x264
git clone --depth 1 git://git.videolan.org/x264
# change to downloaded directory
cd x264
# build x264 on VULCAN APP
vulcan build -v -s . -c "./configure --enable-static --enable-shared --disable-asm --prefix=/app/vendor/x264 && make && make install"
# once done download and extract to the local vulcan app to vendor/x264
# add the files to git and push to the your DESTINATION APP FOO on heroku
git add .
git commit -m "x264"
git push heroku master
#########
# MP3LAME
# Download the latest source (http://lame.sourceforge.net/download.php) for Lame mp3
# extract it
# cd to the lame dir
# build LAMEmp3 on VULCAN APP
vulcan build -v -s . -c "./configure --enable-shared --disable-asm --prefix=/app/vendor/mp3lame && make && make install"
# download and extract the files to the local VULCAN APP to vendor/mp3lame
# add the files to your DESTINATION APP FOO git and push to heroku
git add .
git commit -m "mp3lame"
git push heroku master
#################
# OGG VOBIS
# Download latest ogg source from http://www.xiph.org/downloads/
# and extract to foo and cd to the dir
vulcan build -v -s . -c "./configure --enable-shared --disable-asm --prefix=/app/vendor/libogg && make && make install"
# download and extract the files to the local VULCAN APP
## download and extract the tar to the VULCAN to vendor/libobb
# add files to git and push to the heroku foo app
##Download latest vorbis source from http://www.xiph.org/downloads/ and extract to foo and cd to the dir
vulcan build -v -s . -c "./configure --enable-shared --disable-asm --prefix=/app/vendor/libvorbis && make && make install"
#the above didn't work but this did running from the libvorbis-1.3.3 dir so my ogg compile must have been wrong
vulcan build -v -d http://atmos-vulcan.herokuapp.com/output/128cbd68-ddc3-4888-8bdf-f93c1dcb8ea1
## once done download and extract the tar to the vulcan app to vendor/libvorbis
# add files to git and push to the heroku foo app
git add .
git commit -m "ogg"
git push heroku master
############
## FFMPEG ##
############
# Now we are finally ready to compile ffmpeg with these dependancies
# Download FFMPEG
git clone --depth 1 git://source.ffmpeg.org/ffmpeg
# cd to ffmpeg
cd ffmpeg
#
# You have to specify which codecs you are using for your app
# The following snippet has to be revised by you. delete parameters you dont use.
# In my case I explicit --enable-avfilter
#
#
# Snippet WITHOUT VORBIS but libavfilter enabled
#
vulcan build -v -s . -c "./configure --enable-shared --enable-gpl --enable-libx264 --enable-libmp3lame --enable-avfilter --disable-asm --prefix=/app/vendor/ffmpeg --extra-cflags='-I/app/vendor/x264/include -I/app/vendor/mp3lame/include' --extra-ldflags='-L/app/vendor/x264/lib -L/app/vendor/mp3lame/lib' && make && make install"
#
# Snippet WITH LIB VORBIS
vulcan build -v -s . -c "./configure --enable-shared --enable-gpl --enable-libx264 --enable-libvorbis --enable-libmp3lame --disable-asm --prefix=/app/vendor/ffmpeg --extra-cflags='-I/app/vendor/x264/include -I/app/vendor/mp3lame/include' --extra-ldflags='-L/app/vendor/x264/lib -L/app/vendor/mp3lame/lib' && 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
# create a vendor directory in your REAL APP
mkdir /path/to/your/real/app/vendor/ffmpeg
# copy the complete downloaded and extracted content to your REAL APP Folder /vendor
# It then looks something similar like this:
# /vendor/ffmpeg
# /vendor/gems
# /vendor/mp3lame
# /vendor/x264
mv ffmpeg/* /path/to/your/real/app/vendor/ffmpeg/
# cd to your app then:
# run 'heroku config' and look at the currently set value for PATH. overwriting it will break your app.
# make sure you are simply APPENDING 'vendor/ffmpeg/bin' AND ALL OTHER BINS (e.g. 'vendor/x264/bin', 'vendor/mp3lame/bin') to whatever is already set
heroku config:set PATH=bin:vendor/x264/bin:vendor/mp3lame/bin:vendor/ffmpeg/bin:vendor/bundle/ruby/1.9.1/bin:/usr/local/bin:/usr/bin:/bin -a yourapp
# use the same method to set the Shared Libraries path:
heroku config:set LD_LIBRARY_PATH=vendor/ffmpeg/lib:vendor/x264/lib:vendor/mp3lame/lib:/usr/local/lib -a yourapp
git add .
git commit -m "vendor ffmpeg"
git push heroku master
#####################
# I hope you enjoy! #
# RATE and FORK #
#####################
# In CARRIERWAVE for example I use this (like https://github.com/carrierwaveuploader/carrierwave)
puts system %Q{ffmpeg -y -i "#{current_path}" -f wav "#{tempname}" > /dev/null 2>&1}
# Or with StreamIO (https://github.com/streamio/streamio-ffmpeg)
movie = FFMPEG::Movie.new(current_path)
watermarking_parameter = "-i public/watermark/#{ENV['WATERMARK_FILENAME']} -loop 1 -filter_complex '[1]afade=t=in:ss=0:d=1[4];[4]afade=t=out:st=#{self.evaluate_length-2}:d=2[5];[5][0]amix=duration=shortest[out]' -map [out]"
movie.transcode(current_path, watermarking_parameter)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment