Search code examples
herokuffmpeg

How to get ffmpeg to run on Heroku? (libpulsecommon-15.99.so error)


I'm trying to run ffmpeg on Heroku using an Aptfile (for use in a Flask app where I want to be able to perform audio conversions using pydub, which works fine locally.)

# Aptfile
libsndfile1
libsndfile1-dev
ffmpeg
libvpx7
libpulse0
pulseaudio

I've got these buildpacks:

# Output from `heroku buildpacks`
1. heroku-community/apt
2. heroku/python

And I keep getting this error with a simple heroku run 'ffmpeg --version':

ffmpeg: error while loading shared libraries: libpulsecommon-15.99.so: cannot open shared object file: No such file or directory

This is on Heroku-22, but I was getting the same error on Heroku-20.

Now I've spent hours on this and I'm still confused as to...

  1. What is libpulsecommon-15.99.so even part of?
  2. Is it a case of the library not being installed? Or being installed but not found?
  • ls $HOME/.apt/usr/lib/x86_64-linux-gnu | grep libpulse (where $HOME is /app/) gives:
libpulse-simple.so.0
libpulse-simple.so.0.1.1
libpulse.so.0
libpulse.so.0.24.1
  • echo $LD_LIBRARY_PATH returns /app/.heroku/vendor/lib:/app/.heroku/python/lib:/app/.apt/usr/lib/x86_64-linux-gnu:/app/.apt/usr/lib/i386-linux-gnu:/app/.apt/usr/lib:

I'm lost and these are hours of my life I'm not going to get back 🤔😅


I'm also wondering if there's much a point trying to get ffmpeg to work on Heroku this way: with the dependencies listed above (in the Aptfile), I'm already at 487 MB in slug size (out of a 300 MB soft limit, 500 MB hard limit), for a codebase under 1 MB.

Any help welcome. I'll update the question as needed.


Solution

  • What is libpulsecommon-15.99.so even part of?

    On Ubuntu 22.04, upon which the Heroku 22 stack is based, it is part of the libpulse0 package that you have already included in your Aptfile. I'm not sure why it isn't being found at runtime.

    Instead of installing via Ubuntu packages, you might try a dedicated FFmpeg buildpack. This one looks pretty popular.

    Something like this should do it:

    1. heroku buildpacks:remove heroku-community/apt
    2. heroku buildpacks:add --index 1 https://github.com/jonathanong/heroku-buildpack-ffmpeg-latest.git
    3. git rm Aptfile
    4. git commit