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):
- 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:
-
export LD_LIBRARY_PATH=/home/myusername/
-
/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.












May 5th, 2008 at 22:43
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.
May 6th, 2008 at 20:36
I updated the post to include information you need.
July 7th, 2008 at 15:47
Hay I'm having troubles with testing
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!
July 7th, 2008 at 15:50
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
July 7th, 2008 at 15:56
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
July 7th, 2008 at 16:18
Any between-angle-brackets code is automatically discarded.
Avoid using angle brackets (as in PHP's start/end tags), and everything should be fine.
July 8th, 2008 at 2:27
K, thanks for the suggestion trying again
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");
July 8th, 2008 at 17:15
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).
August 20th, 2008 at 12:08
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.