ffmpeg 编译问题:avcodec_find_decoder 总是返回null [英] ffmpeg compilation problem: avcodec_find_decoder always returns null

查看:213
本文介绍了ffmpeg 编译问题:avcodec_find_decoder 总是返回null的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最近尝试通过从源代码下载和编译 ffmpeg 来升级我在 Mac OS X 应用程序中使用的 ffmpeg 库.

I recently tried to upgrade the ffmpeg libraries I use in my Mac OS X application by downloading and compiling ffmpeg from source.

我的代码与 Windows 上相同版本的预编译库一起正常工作.在 Mac OS X 上,该库似乎可以工作(它可以打开文件并找到使用的流和编解码器),但是当它到达 avcodec_find_decoder 时,此函数始终返回 null.

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.

该代码适用于旧版本的库(一年前在 Mac OS X 10.5 上编译)

The code has worked with an older version of the library (compiled a year ago on Mac OS X 10.5)

我配置了 fmpeg 使用

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

我检查了 config.mak,它似乎启用了我尝试过的文件类型的解码器(ogg、vorbis、avi、mkv、...)我还检查了是否使用了正确的头文件以及是否使用了新编译的库.

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

进一步检查,似乎 av_codec_next(NULL) 也返回 null,这意味着没有可用的单个编解码器,或者 utils.c 中的 first_avcodec 未设置(我实际上根本没有找到此变量已设置,我会假设 av_register_all,但我在那里找不到)

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.

基本上,我只在函数顶部调用了 av_register_all().现在,在此之后添加 avcodec_register_all() 时,我的代码再次运行.我不明白为什么,因为从查看源代码来看,avcodec_register_all() 应该由 av_register_all() 调用.

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.

参见 http://www.ffmpeg.org/doxygen/trunk/allformats_8c-source.html#l00039 为源代码

这篇关于ffmpeg 编译问题:avcodec_find_decoder 总是返回null的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆