ffmpeg-php "dyld: Symbol not found: _avcodec_init"

Problems with the Mac OS X version of XAMPP, questions, comments, and anything related.

ffmpeg-php "dyld: Symbol not found: _avcodec_init"

Postby kinesias » 23. April 2011 14:40

Hi folks,

I'm stuck with an installation of ffmpeg-php on my XAMPP under MacOs 10.6 Snow Leopard.

When I start my server, it prompts the following messages to the error_log:
Code: Select all
dyld: lazy symbol binding failed: Symbol not found: _avcodec_init
  Referenced from: /Applications/XAMPP/xamppfiles/lib/php/php-5.3.1/extensions/no-debug-non-zts-20090626/ffmpeg.so
  Expected in: flat namespace

dyld: Symbol not found: _avcodec_init
  Referenced from: /Applications/XAMPP/xamppfiles/lib/php/php-5.3.1/extensions/no-debug-non-zts-20090626/ffmpeg.so
  Expected in: flat namespace

These are the steps I've done so far:
1. I installed ffmpeg via macports, it all worked fine. these are my ffmpeg entries I get when typing "ffmpeg" into the terminal (shell):
Code: Select all
FFmpeg version 0.6.1, Copyright (c) 2000-2010 the FFmpeg developers
  built on Apr 22 2011 16:09:09 with gcc 4.2.1 (Apple Inc. build 5666) (dot 3)
  configuration: --prefix=/opt/local --enable-gpl --enable-postproc --enable-swscale --enable-avfilter --enable-avfilter-lavf --enable-libmp3lame --enable-libvorbis --enable-libtheora --enable-libdirac --enable-libschroedinger --enable-libfaac --enable-libfaad --enable-libxvid --enable-libx264 --enable-libvpx --enable-libspeex --enable-nonfree --mandir=/opt/local/share/man --enable-shared --enable-pthreads --disable-indevs --cc=/usr/bin/gcc-4.2 --arch=x86_64
  libavutil     50.15. 1 / 50.15. 1
  libavcodec    52.72. 2 / 52.72. 2
  libavformat   52.64. 2 / 52.64. 2
  libavdevice   52. 2. 0 / 52. 2. 0
  libavfilter    1.19. 0 /  1.19. 0
  libswscale     1.11. 0 /  1.11. 0
  libpostproc   51. 2. 0 / 51. 2. 0

2. I downloaded ffmpeg-php from sourceforge and compiled it as 32 bit:
Code: Select all
 ./configure CFLAGS="-arch i386 $CFLAGS" CCFLAGS="-arch i386 $CCFLAGS" \
>  CXXFLAGS="-arch i386 $CXXFLAGS" LDFLAGS="-arch i386 $LDFLAGS" --with-php-config=/Applications/XAMPP/xamppfiles/bin/php-config --with-ffmpeg=/opt/local
checking for grep that handles long lines and -e... /usr/bin/grep
checking for egrep... /usr/bin/grep -E
checking for a sed that does not truncate output... /usr/bin/sed
checking for cc... cc
checking for C compiler default output file name... rm: a.out.dSYM: is a directory
checking whether the C compiler works... yes
checking whether we are cross compiling... no
checking for suffix of executables...
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether cc accepts -g... yes
checking for cc option to accept ISO C89... none needed
checking how to run the C preprocessor... cc -E
checking for icc... no
checking for suncc... no
checking whether cc understands -c and -o together... yes
checking for system library directory... lib
checking if compiler supports -R... no
checking if compiler supports -Wl,-rpath,... yes
checking build system type... i386-apple-darwin10.7.0
checking host system type... i386-apple-darwin10.7.0
checking target system type... i386-apple-darwin10.7.0
checking for PHP prefix... /Applications/XAMPP/xamppfiles
checking for PHP includes... -I/Applications/XAMPP/xamppfiles/include/php/php-5.3.1 -I/Applications/XAMPP/xamppfiles/include/php/php-5.3.1/php -I/Applications/XAMPP/xamppfiles/include/php/php-5.3.1/php/main -I/Applications/XAMPP/xamppfiles/include/php/php-5.3.1/php/TSRM -I/Applications/XAMPP/xamppfiles/include/php/php-5.3.1/php/Zend -I/Applications/XAMPP/xamppfiles/include/php/php-5.3.1/php/ext -I/Applications/XAMPP/xamppfiles/include/php/php-5.3.1/php/ext/date/lib -I/Applications/XAMPP/xamppfiles/include
checking for PHP extension directory... /Applications/XAMPP/xamppfiles/lib/php/php-5.3.1/extensions/no-debug-non-zts-20090626
checking for PHP installed headers prefix... /Applications/XAMPP/xamppfiles/include/php/php-5.3.1/php
checking if debug is enabled... no
checking if zts is enabled... no
checking for re2c... no
configure: WARNING: You will need re2c 0.13.4 or later if you want to regenerate PHP parsers.
checking for gawk... no
checking for nawk... no
checking for awk... awk
checking if awk is broken... no
checking for ffmpeg support... yes, shared
checking whether to force gd support in ffmpeg-php... no
checking for ffmpeg headers... ...found in /usr/local/include/libavcodec
checking for ffmpeg libavcodec.so... ...found in /usr/lib
checking for ffmpeg swscale support... yes
checking for ld used by cc... /usr/llvm-gcc-4.2/libexec/gcc/i686-apple-darwin10/4.2.1/ld
checking if the linker (/usr/llvm-gcc-4.2/libexec/gcc/i686-apple-darwin10/4.2.1/ld) is GNU ld... no
checking for /usr/llvm-gcc-4.2/libexec/gcc/i686-apple-darwin10/4.2.1/ld option to reload object files... -r
checking for BSD-compatible nm... /usr/bin/nm
checking whether ln -s works... yes
checking how to recognize dependent libraries... pass_all
checking for ANSI C header files... yes
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking dlfcn.h usability... yes
checking dlfcn.h presence... yes
checking for dlfcn.h... yes
checking the maximum length of command line arguments... 196608
checking command to parse /usr/bin/nm output from cc object... ok
checking for objdir... .libs
checking for ar... ar
checking for ranlib... ranlib
checking for strip... strip
checking for dsymutil... dsymutil
checking for nmedit... nmedit
checking for -single_module linker flag... yes
checking for -exported_symbols_list linker flag... yes
checking if cc supports -fno-rtti -fno-exceptions... no
checking for cc option to produce PIC... -fno-common
checking if cc PIC flag -fno-common works... yes
checking if cc static flag -static works... no
checking if cc supports -c -o file.o... yes
checking whether the cc linker (/usr/llvm-gcc-4.2/libexec/gcc/i686-apple-darwin10/4.2.1/ld) supports shared libraries... yes
checking dynamic linker characteristics... darwin10.7.0 dyld
checking how to hardcode library paths into programs... immediate
checking whether stripping libraries is possible... yes
checking if libtool supports shared libraries... yes
checking whether to build shared libraries... yes
checking whether to build static libraries... no

creating libtool
appending configuration tag "CXX" to libtool
configure: creating ./config.status
config.status: creating config.h
config.status: config.h is unchanged
kinesias:ffmpeg-php-0.6.0 matthias_lang$ make
/bin/sh /applications/xampp/xamppfiles/ffmpeg-php-0.6.0/libtool --mode=install cp ./ffmpeg.la /applications/xampp/xamppfiles/ffmpeg-php-0.6.0/modules
cp ./.libs/ffmpeg.so /applications/xampp/xamppfiles/ffmpeg-php-0.6.0/modules/ffmpeg.so
cp ./.libs/ffmpeg.lai /applications/xampp/xamppfiles/ffmpeg-php-0.6.0/modules/ffmpeg.la
Libraries have been installed in:

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 `DYLD_LIBRARY_PATH' environment variable
     during execution

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'.

kinesias:ffmpeg-php-0.6.0 matthias_lang$ make install
Installing shared extensions:     /Applications/XAMPP/xamppfiles/lib/php/php-5.3.1/extensions/no-debug-non-zts-20090626/

What do you think? Please help me, this problem is driving me nuts....
Thanks, Matthias
Posts: 2
Joined: 23. April 2011 14:09

Re: ffmpeg-php "dyld: Symbol not found: _avcodec_init"

Postby stefano.sala » 05. May 2011 08:16

Same error here. Did you manage to solve this issue?

Posts: 1
Joined: 05. May 2011 08:15

Re: ffmpeg-php "dyld: Symbol not found: _avcodec_init"

Postby kinesias » 05. May 2011 08:35

unfortunately not, but I have developed my own ffmpeg-php version. I hate those extensions …
I use regular expressions to get all the data I need from the ffmpeg -i entry: (bitrate, fps, dimensions of the movie etc)
I grab a poster frame from the middle of the movie and correct the aspect ratio, if it is anamorphic (cinemascope).

That code is a BEAST:

Code: Select all

echo $file = 'movie.mov';
echo "<p>";
$myThumbnail = makeThumb(2,$file)."<p>";
echo "<p>duration is ".getMovie("duration",$file);
echo "<p>start seconds is ".getMovie("start",$file);
echo "<p>fps are: ".getMovie("fps", $file)."<p>";
echo "height is: " .getMovie("height",$file)."<p>";
echo "width is: ".getMovie("width",$file)."<p>";
echo "ratio is ".getMovie("ratio",$file)."<p>";
echo "bitrate is: ".getMovie("bitrate",$file)."<p>";

function getMovie($var,$file) {
   //load file
   passthru("/usr/local/bin/ffmpeg -i ".$file." 2>&1");
   $output= ob_get_contents();
   //echo "<pre>".$output."</pre><br/>"; //the full output
   //get fps
   $fpsArray=preg_match($search, $output, $matches, PREG_OFFSET_CAPTURE);
   $fpsArray = explode(",",$matches[1][0]); //split fps value
   $count =  count($fpsArray)-1;
   $fps = number_format($fpsArray[$count],0);
   if ($var =="fps"){
           return $fps;
   //get dims
   $count = count($fpsArray)-3;
   $dims = $fpsArray[$count];
   list($origWidth, $origHeight) = explode('x', $dims); //720x552 [DAR ] // !DAR important if cinemascope!!
   $origHeight = explode("[",$origHeight);
   $origHeight = $origHeight[0];
   //get DAR and fix anamorphic dimensions
   $search='/DAR (.*?)[]]/';
   $darArray =preg_match($search, $output, $matches, PREG_OFFSET_CAPTURE);
   $darArray = $matches[1][0];
   if ($darArray <> "") {list($darWidth, $darHeight) = explode(':', $darArray);};
   //echo "darwidth".$darWidth;echo "darHeight".$darHeight;
   //get ratio
   if ($darWidth <> "")
         $ratio = number_format($darWidth/$darHeight, 2)."ANAMORPHIC!";}
   if ($darWidth == "")
         $ratio = number_format($origWidth/$origHeight, 2);
      if ($var =="ratio"){
      return $ratio;
   //get width
   if ($var =="width"){
      if (!isset($darArray))   {
         return $origWidth;
         return floor($origHeight*($darWidth/$darHeight)); // I use floor, because I don't care about 1 pixel ... :)
   //   get height      
   if ($var =="height"){
      return $origHeight; //height remains always the same, even with anamorphic dimensions
   //get bitrate
   $count = count($fpsArray)-2;
   $bitrate = $fpsArray[$count];
   if ($var =="bitrate"){
           return $bitrate;
   //get duration
   $search='/Duration: (.*?)[.]/';
   $duration=preg_match($search, $output, $matches, PREG_OFFSET_CAPTURE);
   $duration = $matches[1][0];
        // fix wrong start seconds - iTunes sometimes adds wrong metadata to movies
        $start = ob_get_contents();
        $search='/start: (.*?)[,]/'; //get start seconds
        $start=preg_match($search, $output, $matches, PREG_OFFSET_CAPTURE);
        $start = $matches[1][0];
        if ($var =="start"){
           return $start;
        $start = (float)$start; //convert string to float
        $startFrames = floor($start*$fps); //convert seconds to frames, round to integer
        if ($startFrames < 0){$startFrames = $startFrames * (-1);}; //convert to absolute value, yes I am lazy
        if ($start <> 0) {/*echo "<br>ALARM<br>";*/};
   if ($var == "duration"){
      $duration = framesToTimecode(timecodeToFrames($duration,$fps) - $startFrames, $fps);;
      return $duration;
// get a poster frame from the midpoint of the movie
function makeThumb($position, $file){
   $fps = getMovie("fps",$file);
   $duration = getMovie("duration",$file);
   if ($position == ""){$position = 2;}; //grab frame from the middle of the clip by default
   $framesDuration = timecodeToFrames($duration, $fps);
      $newTimecode = $framesDuration/$position;
   $newTimecode = framesToTimecode($newTimecode,$fps);
   //echo $newTimecode;
   //exec shell command, has to be exactly in this order, otherwise it takes hours to render a poster frame from a two hours movie
   $string = "ffmpeg -ss ".$newTimecode." -i ".$file."  posterFrame.jpg  -r 1 -vframes 1 -an -vcodec mjpeg";
   //echo "<p>".$string;


// some simple math to convert timecode to frames
function timecodeToFrames($timecode, $fps){
list($hours, $mins, $secs, $frms) = explode(':', $timecode);
return $hours*$fps*3600 + $mins *$fps*60 +$secs*$fps + $frms;

function framesToTimecode($frms,$fps){
   $hours = floor($frms / (3600 * $fps));
      $frms = $frms - ($hours * 3600 * $fps);
   $mins = floor($frms / (60*$fps));
      $frms = $frms - ($mins * 60 * $fps);
   $secs = floor($frms / ($fps));
   $frms = $frms - ($secs * $fps);
       // leading zeroes
   if ($hours <10){$hours = "0".$hours;};
   if ($mins <10){$mins = "0".$mins;};
   if ($secs <10){$secs = "0".$secs;};
   if ($frames <10){$frames = "0".$frames;};
   return $hours.":".$mins.":".$secs.":".$frms;


Have fun with the code, it is work in progress
Posts: 2
Joined: 23. April 2011 14:09

Re: ffmpeg-php "dyld: Symbol not found: _avcodec_init"

Postby jstitch » 10. November 2011 16:48

kinesias, why not use the output of the ffprobe program instead of the ffmpeg -i one? Just to gather a media file metadata would be moure easier to parse with that program don't you think?

EDIT: wait! it gives just the same output! the difference is that ffmpeg -i expects an output file to be given, so in fact it must use ffprobe to display the metadata. I suggest, though, to use the ffprobe program, since that is the correct tool...
Posts: 1
Joined: 10. November 2011 16:46
XAMPP Version: 1.7.1
Operating System: Linux

Return to XAMPP for Mac OS X

Who is online

Users browsing this forum: No registered users and 2 guests