I recently tried to upgrade the ffmpeg libraries I use in my Mac OS X application by downloading and compiling ffmpeg from source.
My code works correctly with pre-compiled libraries of the same version on windows. On Mac OS X, the library appears to work (it can open the file and find the streams and codecs used), but when it gets to avcodec_find_decoder, this function always returns null.
The code has worked with an older version of the library (compiled a year ago on Mac OS X 10.5)
I configured fmpeg using
./configure --extra-cflags="-arch i386" --extra-ldflags='-arch i386' --arch=x86_32 --target-os=darwin --enable-cross-compile --disable-indev=jack --enable-shared --disable-static
I checked config.mak, and it appears to have the decoders for the file types I tried enabled (ogg, vorbis, avi, mkv, ...) I also checked that the correct header files have been used and that the newly compiled library is used.
I have found only some older posts relating to this issue, but without any solution:
http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/2007-January/021399.html
http://libav-users.943685.n4.nabble.com/avcodec-find-decoder-problem-td944800.html
Edit: checking further, it appears av_codec_next(NULL) returns null as well, which means there isn't a single codec available, or that first_avcodec in utils.c is not set (I actually haven't found at all where this variable is set, I would have assumed av_register_all, but I can't find it there)
I've found a solution for my problem, even though I would still be interested if anyone can help me with an explanation of my problem.
Basically, I was calling only av_register_all() at the top of my function. Now when adding avcodec_register_all() after this, my code works again. I don't understand why though, because avcodec_register_all() should be called by av_register_all() from looking at the source code.
See http://www.ffmpeg.org/doxygen/trunk/allformats_8c-source.html#l00039 for the source code
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With