Autarchy of the Private Cave

Science, Society, Programming and Hobbies

  • Exits

  • Categories

  • Archives

  • Visitors' track

    Locations of visitors to this page
  • Tags list

  • Earn and spend


  • Exits

  • Ratings

    Science Blogs - Blog Top Sites website monitoring service
  • 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):
      PHP:
      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 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.

    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

    CODE:
    1. export LD_LIBRARY_PATH=/home/myusername/
    2. /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 This

    9 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.

    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>

     
    Close
    E-mail It