Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.3k views
in Technique[技术] by (71.8m points)

macos - ffmpeg compilation problem: avcodec_find_decoder always returns null

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)

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...