FFMPEG and PHP on mac does`t work

2020-03-27 04:56发布

问题:

I need your help. Currently I use Mac OS X 10.9.4 and xampp apache 1.8.3-3. I need to use ffmpeg (version 3.2) to convert video files via php exec() but I cannot make it work. I did some testing running the terminal command line and the system operates normally. Only in php it doesn't work. ffmpeg was compiled and installed through the brew.

I ran the following test:

exec("/usr/local/Cellar/ffmpeg/2.3/bin/ffmpeg -i /Applications/XAMPP/xamppfiles/htdocs/teste/trailer.mp4 /Applications/XAMPP/xamppfiles/htdocs/teste/trailer2.flv 2>&1", $o, $v);
var_dump($o);
var_dump($v);

and got the following:

array(4) { 
    [0]=> string(51) "dyld: Symbol not found: __cg_jpeg_resync_to_restart" 
    [1]=> string(82) "Referenced from: /System/Library/Frameworks/ImageIO.framework/Versions/A/ImageIO" 
    [2]=> string(63) "Expected in: /Applications/XAMPP/xamppfiles/lib/libJPEG.dylib" 
    [3]=> string(67) " in /System/Library/Frameworks/ImageIO.framework/Versions/A/ImageIO" } int(133)

回答1:

problem is linked to DYLD_LIBRARY_PATH being set to xampp libraries folder

try unsetting this before exec any one of these before exec will work

exec('unset DYLD_LIBRARY_PATH ;');
putenv('DYLD_LIBRARY_PATH');
putenv('DYLD_LIBRARY_PATH=/usr/bin');