Autarchy of the Private Cave

Tiny bits of bioinformatics, [web-]programming etc

    Instructions on installing libmp3lame-enabled ffmpeg on shared linux hosting

    12th March 2008

    Note: this post is based on the comment by Simon, who generously shared his experience.

    Step-by-step:

    • Download the compiled ffmpeg with libmp3lame support (direct download links: older version ffmpeg.with.lame and newer version ffmpeg.2007-10-28.with-libmp3lame-support).
    • Rename the downloaded executable file to “ffmpeg” (no extension), upload it to the directory on your server (in this example /home/myusername/).
    • Download libmp3lame.so.0.
    • Upload libmp3lame.so.0 to the same directory where you placed ffmpeg in.
    • Create a php file with the following code (remember to change the paths to your own, where you actually uploaded binaries in previous steps):
      1. <?php
      2. exec("export LD_LIBRARY_PATH=/home/myusername/");
      3. echo passthru("/home/myusername/ffmpeg -formats");
      4. ?>
    • If you access that PHP file with your browser, you should be able to see a list of formats which are supported by ffmpeg, and if you find “EA libmp3lame” somewhere in the output, then it means you now can Encode Audio in libmp3lame!
    • If that doesn’t work for you: LD_LIBRARY_PATH can be a protected variable in PHP (you can check for this by searching for the “safe_mode_protected_env_vars” value in phpinfo() output). The workaround here can be to write your commands to a file from php, then chmod that file with 0755 permissions (rwx-rx-rx), and run the file through exec(). In this way, PHP is not changing the LD_LIBRARY_PATH, but telling the server to run a file, which tells the server to change it. This method worked for the original author of these instructions.

    For passing arguments to the PHP wrapper script – check out PHP’s $argv variable (more on this here). If you decided to use shell-script as a wrapper for “export LD_LIBRARY_PATH”, then using $1, $2 etc will allow you to pass parameters to the shell script, e.g. in the example below

    1. #!/bin/bash
    2. export LD_LIBRARY_PATH=/home/myusername/
    3. /home/myusername/ffmpeg -i /home/myusername/$1 $2 /home/myusername/$3

    you could pass “input file” as first argument, “parameters” as second and “output file” as third to make such a wrapper script work.

    Share

    19 Responses to “Instructions on installing libmp3lame-enabled ffmpeg on shared linux hosting”

    1. Mark Says:

      I’ve created the file, running the command “-formats” and it is indeed all working great.

      However, now I want to pass in a Parameter to my command-file but not being a huge linux guy, I’m not certain of the commands (like in DOS it would be %1 %2 %3, etc).

      Final help from anyone?

      Thanks.

    2. Bogdan Says:

      I updated the post to include information you need.

    3. Trozza Says:

      Hay I’m having troubles with testing :P

      I managed to get to the second last bullet point, the page is blank when executed, so I had a look at the last bullet point and found LD_LIBRARY_PATH was a protected variable, so I tried the workaround exec(), however I’m still getting a blank page, so thought I’d check that I’m doing it correctly, as i’ve never used the exec() command before.
      ffmpegtest.php file is executable and looks like

      and my test.php file looks like below

      and I’ve uploaded ffmpeg and libmp3lame.so to the trozza folder.

      Thanks for any help you can provide, site is excellent!

    4. Trozza Says:

      Sorry for the second post but couldn’t edit previous post and forgot to add that i’m on a godaddy shared linux host

      Troz

    5. Trozza Says:

      crap! sorry for flooding the thread but just realized the code I had posted didn’t show up

      ffmpegtest.php looks like

      test.php looks like

    6. Bogdan Says:

      Any between-angle-brackets code is automatically discarded.
      Avoid using angle brackets (as in PHP’s start/end tags), and everything should be fine.

    7. Trozza Says:

      K, thanks for the suggestion trying again :P

      ffmpegtest.php looks like
      exec(“export LD_LIBRARY_PATH=/home/content/t/r/o/troxxxx/html/trozza/”);
      echo passthru/home/content/t/r/o/troxxxx/html/trozza/ffmpeg -formats”);

      and test.php looks like
      exec(“ffmpegtest.php”);

    8. Bogdan Says:

      you don’t need that test.php

      just call ffmpegtest.php from your browser; only check that syntax is correct (you omitted opening brace and quote in your comment above):

      exec(“export LD_LIBRARY_PATH=/home/content/t/r/o/troxxxx/html/trozza/”);
      echo passthru(“/home/content/t/r/o/troxxxx/html/trozza/ffmpeg -formats”);

      also, do not forget to set “executable” permission onto ffmpeg (if you have shell access, do chmod a+x ffmpeg in the directory where ffmpeg is located; if you do not have shell access, use your FTP manager to set “execute” permission for user/group/others).

    9. bw Says:

      Hi I’ve followed the guide, but my ffmpeg.php file return a blank page. I aaded a line phpinfo() to the file, and it does appear that safe_mode_protected_env_vars is set.

      In your guide you say….

      If that doesn’t work for you: LD_LIBRARY_PATH can be a protected variable in PHP (you can check for this by searching for the “safe_mode_protected_env_vars” value in phpinfo() output). The workaround here can be to write your commands to a file from php, then chmod that file with 0775 permissions (rwx-rx-rx), and run the file through exec(). In this way, PHP is not changing the LD_LIBRARY_PATH, but telling the server to run a file, which tells the server to change it. This method worked for the original author of these instructions.

      Can you provide more details on this? Maybe a code example?

      Thanks.

    10. Jake Says:

      Hi!

      I’m having the same problem as Bw, a blank page using godaddy shared hosting, could someone please give us a code example to workaround the LD_LIBRARY_PATH protected?

      Thanks.

    11. Bogdan Says:

      There is a sample shell script at the end of the post to circumvent that problem. Disclaimer: I haven’t tested if it actually helps, and it needs a little more work and adaptation for each case to be functional.

    12. Angela Roberts Says:

      This is sooo awesome and I got it to work so that I could run hwdmediashare. I was thinking I had everything working and then I tried to convert a video and I got the following error.

      Unsupported codec (id=73728) for input stream #0.1

      after the conversion ran. I researched that and it appears that this version of ffmpeg doesn’t have aac conversion. Maybe they are an older version that won’t convert aac??? Is there a way around this??

      Thanks in advance for your help!!!

      Angela

    13. Bogdan Says:

      Might be really the problem of the older version.

      The proper solution is to recompile ffmpeg from the most fresh sources (SVN).
      I cannot do this at the moment, so you may need to compile one yourself.

      The set of configuration switches for the compilation of “compatible” ffmpeg is available for each version I’ve posted on that page.

    14. Patryk Moura Says:

      Im experiencing the following trouble:
      [Tue Feb 14 08:54:09 2012] [error] [client 187.14.166.219] /home/vamolaco/ffmpeg: error while loading shared libraries: libz.so.1: cannot open shared object file: No such file or directory

      Where can I download this libz.so.1???

      Thanks in advance!!!!

    15. Bogdan Says:

      Patryk: depending on your OS, in Debian/Ubuntu this missing file can be found either in zlib1g or lib64z1 packages, and in RPM-based distros look for zlib-* packages.

    16. Patryk Moura Says:

      Ive tried to install in my ubuntu (notebook pc), and move to there (ftp sixserve.com), but i got nothing =( now is asking for libavdevice.so.53, ive copied the lib from my notebook and uploaded tp the ftp, and keep sayin that ive got no permission or the file doesnt exist… and ive changed the permissions to 0777 and got nothing too =\
      can u help?
      thanks man, thanks A LOT!

    17. Mitja Says:

      Hi can you try to compile lame into ffmpeg as I am using some php script where I just give path to ffmpeg and can expot Library PATH

    18. Mitja Says:

      whoops here is the right comment: Hi can you try to compile lame into ffmpeg as I am using some php script where I just give path to ffmpeg and can’t expot Library PATH

    19. Bogdan Says:

      @Mitja: sorry, I’m very low on free time right now and at least until the end of this year…
      When I have a bit of spare time, I’ll update the post with instructions on how to compile the most up-to-date version yourself – this isn’t hard at all.
      I’d suggest to first try simply following ffmpeg’s compilation instructions.

      If you can’t export library path from PHP – see the last bullet point of the blog post to circumvent that limitation.

    Leave a Reply

    XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>