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
- exec("export LD_LIBRARY_PATH=/home/myusername/");
- echo passthru("/home/myusername/ffmpeg -formats");
- ?>
- 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
- #!/bin/bash
- 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.
February 20th, 2010 at 8:17
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.
February 20th, 2010 at 12:53
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.
March 21st, 2010 at 11:04
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
March 21st, 2010 at 13:03
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.
February 14th, 2012 at 15:50
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!!!!
February 15th, 2012 at 2:02
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.
February 23rd, 2012 at 5:53
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!
November 13th, 2016 at 15:32
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
November 13th, 2016 at 15:33
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
November 13th, 2016 at 18:42
@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.