FFMPEG-PHP will not load! (been trying to get it working for days)

I have been trying to install ffmpeg-php for days, and I just can’t seem to figure out why it won’t load.

I have done all of the following after extraction, without any errors:

cd /usr/local/src/ffmpeg-php-0.6.0

phpize

./configure

make && make install

I have also added ‘extension=ffmpeg.so’ to the php.ini file and restarted the server.

I run the test command:

php -i | grep ffmpeg

There is no output.

Then I run this command to check if the module is loaded:

php -m

It is clearly not listed.

If I go back to the ffmpeg-php directory and run “make test”, I see a huge list of errors that don’t seem to make sense, and every single test FAILS, with the exception of the ones that are skipped with “reason: ffmpeg extension not loaded”.

I can post the full output if needed.

If anyone thinks they know what the problem is, your help would be infinitely appreciated; I would even be willing to compensate.

Thank you in advance.

Regards,
Morthian

Here is the full output of ‘make test’:

root@server [/usr/local/src/ffmpeg-php-0.6.0]# make test

/bin/sh /usr/local/src/ffmpeg-php-0.6.0/libtool --mode=install cp ./ffmpeg.la /usr/local/src/ffmpeg-php-0.6.0/modules

cp ./.libs/ffmpeg.so /usr/local/src/ffmpeg-php-0.6.0/modules/ffmpeg.so
cp ./.libs/ffmpeg.lai /usr/local/src/ffmpeg-php-0.6.0/modules/ffmpeg.la
PATH="$PATH:/sbin" ldconfig -n /usr/local/src/ffmpeg-php-0.6.0/modules
----------------------------------------------------------------------
Libraries have been installed in:
   /usr/local/src/ffmpeg-php-0.6.0/modules

If you ever happen to want to link against installed libraries
in a given directory, LIBDIR, you must either use libtool, and
specify the full pathname of the library, or use the `-LLIBDIR'
flag during linking and do at least one of the following:
   - add LIBDIR to the `LD_LIBRARY_PATH' environment variable
     during execution
   - add LIBDIR to the `LD_RUN_PATH' environment variable
     during linking
   - use the `-Wl,--rpath -Wl,LIBDIR' linker flag
   - have your system administrator add LIBDIR to `/etc/ld.so.conf'

See any operating system documentation about shared libraries for
more information, such as the ld(1) and ld.so(8) manual pages.
----------------------------------------------------------------------

Build complete.
Don't forget to run 'make test'.


Warning: PHP Startup: Unable to load dynamic library 'modules/pdo.so' - modules/pdo.so: cannot open shared object file: No such file or directory in Unknown on line 0

Warning: PHP Startup: Unable to load dynamic library 'modules/pdo_sqlite.so' - modules/pdo_sqlite.so: cannot open shared object file: No such file or directory in Unknown on line 0

Warning: PHP Startup: Unable to load dynamic library 'modules/sqlite.so' - modules/sqlite.so: cannot open shared object file: No such file or directory in Unknown on line 0

Warning: PHP Startup: Unable to load dynamic library 'modules/phpshield.5.2.lin' - modules/phpshield.5.2.lin: cannot open shared object file: No such file or directory in Unknown on line 0

Warning: PHP Startup: Unable to load dynamic library 'modules/memcache.so' - modules/memcache.so: cannot open shared object file: No such file or directory in Unknown on line 0

Warning: PHP Startup: Unable to load dynamic library 'modules/imagick.so' - modules/imagick.so: cannot open shared object file: No such file or directory in Unknown on line 0

Warning: PHP Startup: Unable to load dynamic library 'modules/pdo_mysql.so' - modules/pdo_mysql.so: cannot open shared object file: No such file or directory in Unknown on line 0

Warning: PHP Startup: Unable to load dynamic library 'modules/ffmpeg.so' - /usr/lib/libavcodec.so.52: undefined symbol: speex_header_free in Unknown on line 0

Warning: PHP Startup: Unable to load dynamic library 'modules/ffmpeg.so' - /usr/lib/libavcodec.so.52: undefined symbol: speex_header_free in Unknown on line 0

Warning: PHP Startup: Unable to load dynamic library 'modules/pdo.so' - modules/pdo.so: cannot open shared object file: No such file or directory in Unknown on line 0

Warning: PHP Startup: Unable to load dynamic library 'modules/pdo_sqlite.so' - modules/pdo_sqlite.so: cannot open shared object file: No such file or directory in Unknown on line 0

Warning: PHP Startup: Unable to load dynamic library 'modules/sqlite.so' - modules/sqlite.so: cannot open shared object file: No such file or directory in Unknown on line 0

Warning: PHP Startup: Unable to load dynamic library 'modules/phpshield.5.2.lin' - modules/phpshield.5.2.lin: cannot open shared object file: No such file or directory in Unknown on line 0

Warning: PHP Startup: Unable to load dynamic library 'modules/memcache.so' - modules/memcache.so: cannot open shared object file: No such file or directory in Unknown on line 0

Warning: PHP Startup: Unable to load dynamic library 'modules/imagick.so' - modules/imagick.so: cannot open shared object file: No such file or directory in Unknown on line 0

Warning: PHP Startup: Unable to load dynamic library 'modules/pdo_mysql.so' - modules/pdo_mysql.so: cannot open shared object file: No such file or directory in Unknown on line 0

Warning: PHP Startup: Unable to load dynamic library 'modules/ffmpeg.so' - /usr/lib/libavcodec.so.52: undefined symbol: speex_header_free in Unknown on line 0

Warning: PHP Startup: Unable to load dynamic library 'modules/ffmpeg.so' - /usr/lib/libavcodec.so.52: undefined symbol: speex_header_free in Unknown on line 0

=====================================================================
PHP         : /usr/local/bin/php
PHP_SAPI    : cli
PHP_VERSION : 5.2.9
ZEND_VERSION: 2.2.0
PHP_OS      : Linux - Linux server.shroomtown.com 2.6.18-028stab059.6-ent #1 SMP Fri Nov 14 15:51:43 MSK 2008 i686
INI actual  : /usr/local/lib/php.ini
More .INIs  :
CWD         : /usr/local/src/ffmpeg-php-0.6.0
Extra dirs  :
VALGRIND    : Not used
=====================================================================
Running selected tests.
FAIL ffmpeg getAudioBitRate test [tests/getAudioBitRate.phpt]
FAIL ffmpeg getAudioChannels test [tests/getAudioChannels.phpt]
FAIL ffmpeg getAudioCodec test [tests/getAudioCodec.phpt]
FAIL ffmpeg getAudioSampleRate test [tests/getAudioSampleRate.phpt]
FAIL ffmpeg getAudioStreamId test [tests/getAudioStreamId.phpt]
FAIL ffmpeg getBitRate test [tests/getBitRate.phpt]
FAIL ffmpeg getDuration test [tests/getDuration.phpt]
FAIL ffmpeg getFileName test [tests/getFileName.phpt]
SKIP ffmpeg getFrame test [tests/getFrame.phpt] reason: ffmpeg extension not loaded
FAIL ffmpeg getFrameCount test [tests/getFrameCount.phpt]
FAIL ffmpeg getFrameHeight test [tests/getFrameHeight.phpt]
FAIL ffmpeg getFrameNumber test [tests/getFrameNumber.phpt]
FAIL ffmpeg getFrameRate test [tests/getFrameRate.phpt]
FAIL ffmpeg getFrameWidth test [tests/getFrameWidth.phpt]
SKIP ffmpeg getFrame backwards test [tests/getFramesBackwards.phpt] reason: ffmpeg extension not loaded
SKIP ffmpeg getFrames forward test [tests/getFramesForward.phpt] reason: ffmpeg extension not loaded
SKIP ffmpeg getFrames forward test [tests/getFramesForwardPassedEnd.phpt] reason: ffmpeg extension not loaded
SKIP ffmpeg getFramesNoArg test [tests/getFramesNoArg.phpt] reason: ffmpeg extension not loaded
FAIL ffmpeg getID3Info() test [tests/getID3Info.phpt]
SKIP ffmpeg get key frames test [tests/getNextKeyFrame.phpt] reason: ffmpeg extension not loaded
SKIP ffmpeg getPTS test (Fixme: This test is no good with robot.avi) [tests/getPTS.phpt] reason: ffmpeg extension not loaded
FAIL ffmpeg getPixelAspectRatio test [tests/getPixelAspectRatio.phpt]
FAIL ffmpeg getPixelFormat test [tests/getPixelFormat.phpt]
FAIL ffmpeg getVideoBitRate test [tests/getVideoBitRate.phpt]
FAIL ffmpeg getVideoCodec test [tests/getVideoCodec.phpt]
FAIL ffmpeg getVideoStreamId test [tests/getVideoStreamId.phpt]
FAIL ffmpeg hasAudio test [tests/hasAudio.phpt]
SKIP ffmpeg test key frame [tests/isKeyFrame.phpt] reason: ffmpeg extension not loaded
FAIL ffmpeg persistent movie test [tests/persistentMovie.phpt]
=====================================================================
Number of tests :   29                21
Tests skipped   :    8 ( 27.6%) --------
Tests warned    :    0 (  0.0%) (  0.0%)
Tests failed    :   21 ( 72.4%) (100.0%)
Expected fail   :    0 (  0.0%) (  0.0%)
Tests passed    :    0 (  0.0%) (  0.0%)
---------------------------------------------------------------------
Time taken      :    4 seconds
=====================================================================

=====================================================================
FAILED TEST SUMMARY
---------------------------------------------------------------------
ffmpeg getAudioBitRate test [tests/getAudioBitRate.phpt]
ffmpeg getAudioChannels test [tests/getAudioChannels.phpt]
ffmpeg getAudioCodec test [tests/getAudioCodec.phpt]
ffmpeg getAudioSampleRate test [tests/getAudioSampleRate.phpt]
ffmpeg getAudioStreamId test [tests/getAudioStreamId.phpt]
ffmpeg getBitRate test [tests/getBitRate.phpt]
ffmpeg getDuration test [tests/getDuration.phpt]
ffmpeg getFileName test [tests/getFileName.phpt]
ffmpeg getFrameCount test [tests/getFrameCount.phpt]
ffmpeg getFrameHeight test [tests/getFrameHeight.phpt]
ffmpeg getFrameNumber test [tests/getFrameNumber.phpt]
ffmpeg getFrameRate test [tests/getFrameRate.phpt]
ffmpeg getFrameWidth test [tests/getFrameWidth.phpt]
ffmpeg getID3Info() test [tests/getID3Info.phpt]
ffmpeg getPixelAspectRatio test [tests/getPixelAspectRatio.phpt]
ffmpeg getPixelFormat test [tests/getPixelFormat.phpt]
ffmpeg getVideoBitRate test [tests/getVideoBitRate.phpt]
ffmpeg getVideoCodec test [tests/getVideoCodec.phpt]
ffmpeg getVideoStreamId test [tests/getVideoStreamId.phpt]
ffmpeg hasAudio test [tests/hasAudio.phpt]
ffmpeg persistent movie test [tests/persistentMovie.phpt]
=====================================================================

Well, your problem is that FFPMEG isn’t loading because you don’t have alot of the dependencies loading (all that stuff about “can’t find modules/xyz.so”. So, get the dependencies loaded then see what you can do.

They are loaded:

# php -m
[PHP Modules]
bcmath
bz2
calendar
ctype
curl
date
dom
exif
filter
ftp
gd
gettext
hash
iconv
imagick
imap
ionCube Loader
json
libxml
mbstring
mcrypt
memcache
mhash
mime_magic
mysql
mysqli
openssl
pcre
PDO
pdo_mysql
pdo_sqlite
pgsql
phpSHIELD
posix
pspell
Reflection
session
SimpleXML
soap
sockets
SPL
SQLite
standard
tidy
tokenizer
wddx
xml
xmlreader
xmlrpc
xmlwriter
xsl
Zend Optimizer
zip
zlib

Your error message begs to differ:

Warning: PHP Startup: Unable to load dynamic library ‘modules/pdo.so’ - modules/pdo.so: cannot open shared object file: No such file or directory in Unknown on line 0

Warning: PHP Startup: Unable to load dynamic library ‘modules/pdo_sqlite.so’ - modules/pdo_sqlite.so: cannot open shared object file: No such file or directory in Unknown on line 0

Warning: PHP Startup: Unable to load dynamic library ‘modules/sqlite.so’ - modules/sqlite.so: cannot open shared object file: No such file or directory in Unknown on line 0

Warning: PHP Startup: Unable to load dynamic library ‘modules/phpshield.5.2.lin’ - modules/phpshield.5.2.lin: cannot open shared object file: No such file or directory in Unknown on line 0

Warning: PHP Startup: Unable to load dynamic library ‘modules/memcache.so’ - modules/memcache.so: cannot open shared object file: No such file or directory in Unknown on line 0

Warning: PHP Startup: Unable to load dynamic library ‘modules/imagick.so’ - modules/imagick.so: cannot open shared object file: No such file or directory in Unknown on line 0

Warning: PHP Startup: Unable to load dynamic library ‘modules/pdo_mysql.so’ - modules/pdo_mysql.so: cannot open shared object file: No such file or directory in Unknown on line 0

Warning: PHP Startup: Unable to load dynamic library ‘modules/ffmpeg.so’ - /usr/lib/libavcodec.so.52: undefined symbol: speex_header_free in Unknown on line 0

Warning: PHP Startup: Unable to load dynamic library ‘modules/ffmpeg.so’ - /usr/lib/libavcodec.so.52: undefined symbol: speex_header_free in Unknown on line 0

Warning: PHP Startup: Unable to load dynamic library ‘modules/pdo.so’ - modules/pdo.so: cannot open shared object file: No such file or directory in Unknown on line 0

Warning: PHP Startup: Unable to load dynamic library ‘modules/pdo_sqlite.so’ - modules/pdo_sqlite.so: cannot open shared object file: No such file or directory in Unknown on line 0

Warning: PHP Startup: Unable to load dynamic library ‘modules/sqlite.so’ - modules/sqlite.so: cannot open shared object file: No such file or directory in Unknown on line 0

Warning: PHP Startup: Unable to load dynamic library ‘modules/phpshield.5.2.lin’ - modules/phpshield.5.2.lin: cannot open shared object file: No such file or directory in Unknown on line 0

Warning: PHP Startup: Unable to load dynamic library ‘modules/memcache.so’ - modules/memcache.so: cannot open shared object file: No such file or directory in Unknown on line 0

Warning: PHP Startup: Unable to load dynamic library ‘modules/imagick.so’ - modules/imagick.so: cannot open shared object file: No such file or directory in Unknown on line 0

Warning: PHP Startup: Unable to load dynamic library ‘modules/pdo_mysql.so’ - modules/pdo_mysql.so: cannot open shared object file: No such file or directory in Unknown on line 0

Warning: PHP Startup: Unable to load dynamic library ‘modules/ffmpeg.so’ - /usr/lib/libavcodec.so.52: undefined symbol: speex_header_free in Unknown on line 0

Warning: PHP Startup: Unable to load dynamic library ‘modules/ffmpeg.so’ - /usr/lib/libavcodec.so.52: undefined symbol: speex_header_free in Unknown on line 0

=====================================================================
PHP : /usr/local/bin/php
PHP_SAPI : cli

PS: just noticed this when I pasted it in, but it seems like it is trying to load the modules twice or three times and still failing.

That’s exactly what I can’t figure out. PHP shows all the modules to be loaded (except ffmpeg of course), but the test does not.

How are you getting that list of loaded modules? Is it running through the same process that the FFMPEG is using?

‘php -m’ in the SSH console displays that list. The modules are also configured to load in the php.ini file.

I run the command ‘php -i | grep ini’ to check which php.ini file is loaded.

Configuration File (php.ini) Path => /usr/local/lib
Loaded Configuration File => /usr/local/lib/php.ini

As you can see in the ‘make test’ output, it is using the same ini file.

PHP         : /usr/local/bin/php
PHP_SAPI    : cli
PHP_VERSION : 5.2.9
ZEND_VERSION: 2.2.0
PHP_OS      : Linux - Linux server.shroomtown.com 2.6.18-028stab059.6-ent #1 SMP Fri Nov 14 15:51:43 MSK 2008 i686
[B]INI actual  : /usr/local/lib/php.ini[/B]
More .INIs  :
CWD         : /usr/local/src/ffmpeg-php-0.6.0
Extra dirs  :
VALGRIND    : Not used

Sorry, what exactly do you mean by this?

Make sure that ffmpeg.so is placed into the same folder to which extension_dir in your php.ini points.

Yes, it is.

The line in ‘php.ini’ reads:
extension_dir = “/usr/local/lib/php/extensions/no-debug-non-zts-20060613”

I can see ffmpeg.so is indeed in this directory.

Pretty much what you did–confirm that you were talking to the same PHP.ini, etc.

What it seems like to me is that you are missing a dependency of those libraries, so it can’t load those libraries. Not certain exactly what it is, but this is the sort of behavior I see when I forget one of the key php DLLs on windows.

My site’s error log is filled with this message (occurring nearly every second):

PHP Warning: PHP Startup: Unable to load dynamic library ‘/usr/local/lib/php/extensions/no-debug-non-zts-20060613/ffmpeg.so’ - /usr/lib/libavcodec.so.52: undefined symbol: speex_header_free in Unknown on line 0

I don’t see errors for other modules; only this one.

I have hardly any knowledge of Linux or maintaining a server, so any suggestions at all would definitely be appreciated.

Well, I’m not a *nix guy (see my avatar), so I don’t have any specific advice. A bit of googling around “/usr/lib/libavocec.so.52” revealed alot of answers–I would try searching on that accompanied by your *nix distro and see if you can find any specific advice.

Not really a C guy either, but I can read the error messagess-basically it is saying that ffmpeg.so is expecting a library (libavcodec.so) that is either missing or is the wrong version. There is probably a bit of residual fallout from the missing library, but if that is the error you are getting, that is the first vector I’d run down.

Error-log wise, I would look for the first few php errors when you start apache. Those could also be very telling. From my experience PHP tries to load lots of stuff on the first hit and can start acting squirrelly if it doesn’t have what it wants then.

I had someone install an ffmpeg library on my server a little while back. I later noticed that the root directory when I log into SSH had been changed for some reason. I don’t remember what it was before (‘/usr/local/bin’ perhaps), but it is now ‘/root’. Could this possibly be causing the error?

(I have been trying to install from ‘/usr/local/src’)

Ffmpeg can be a right pain for dependencies. If possible I now use a fully statically compiled binary (i.e a standalone binary) or use heywatch as an external api when I require server side encoding.