简体   繁体   中英

ffmpeg MAMP “dyld: Library not loaded” error

I am using ffmpeg on Mac OSX 10.7.3 in MAMP through PHP's exec() command, I have an absolute path set to call ffmpeg, eg

/opt/local/bin/ffmpeg -i "/sample.avi"

But I receive the following error -

dyld: Library not loaded: /opt/local/lib/libjpeg.8.dylib  Referenced from: /opt/local/lib/libopenjpeg.1.dylib  Reason: Incompatible library version: libopenjpeg.1.dylib requires version 13.0.0 or later, but libJPEG.dylib provides version 12.0.0

NB ffmpeg was installed through Macports.

It works from the command line.

What to do?

EDIT

I've reopened this - originally thought shell_exec() solved the issue, but infact it should be called differently - and I didn't realise until investigating further today. Here is my code using shell_exec and still giving the error above:

 $cmd = '/opt/local/bin/ffmpeg -h';
 $cmd = escapeshellcmd($cmd) . ' 2>&1';
 $output = shell_exec($cmd);
 var_dump($output);

The problem is that the DYLD_LIBRARY_PATH is set in MAMP and I've installed ffmpeg via macports.

This might not be the best fix but it has me up and running for now:

In the /Applications/MAMP/Library/bin/envvars file and comment the following lines as below:

#DYLD_LIBRARY_PATH="/Applications/MAMP/Library/lib:$DYLD_LIBRARY_PATH"
#export DYLD_LIBRARY_PATH

and restart Apache

Commenting out the line #DYLD_LIBRARY_PATH="/Applications/MAMP/Library/lib:$DYLD_LIBRARY_PATH" will work in the short term but it could break other things, since you're removing the line that MAMP uses to tell the server where it keeps its libraries.

A better solution would be to change the line to this:

DYLD_LIBRARY_PATH="/usr/local/lib:/Applications/MAMP/Library/lib:$DYLD_LIBRARY_PATH"

so that you're just prepending /usr/local/lib: to the already-given path. This tells Apache to look in /usr/local/lib first, and then if that doesn't work, to look in /Applications/MAMP/Library/lib .

So if you install something via, say, Brew and there are two versions, it'll look in the one you installed with Brew first, before it uses whatever came with MAMP, which is more likely to be out of date. But if it's something that only came with MAMP, that you didn't install separately or that is MAMP-specific, you won't break it.

Ensure PHP's exec is using the same shell as you, when you use the commandline.

Probably shell_exec Docs helps.

See as well php shell_Exec not working while the command works in shell .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM