根据这位,可以在android程序里调用ffmpeg的avcodec_version()函数;
下载了最新版的ffmpeg源码(2.4.1),在cygwin里用NDK编译时可能会报错,报错如下;
your_name@AP-CHN-LP140129 /cygdrive/c/Workspace_my/TestApp$ ndk-buildAndroid NDK: WARNING:jni/Android.mk:Prompt: non-system libraries in linker flags: -lffmpegAndroid NDK: This is likely to result in incorrect builds. Try using LOCAL_STATIC_LIBRARIESAndroid NDK: or LOCAL_SHARED_LIBRARIES instead to list the library dependencies of theAndroid NDK: current module[armeabi] Compile thumb : Prompt <= Prompt.cIn file included from jni/ffmpeg/libavutil/avutil.h:289:0, from jni/ffmpeg/libavutil/samplefmt.h:24, from jni/ffmpeg/libavcodec/avcodec.h:31, from jni/Prompt.c:6:jni/ffmpeg/libavutil/common.h:44:32: fatal error: libavutil/avconfig.h: No such file or directory #include "libavutil/avconfig.h" ^compilation terminated./cygdrive/c/Software/android/android-ndk-r10b/build/core/build-binary.mk:447: recipe for target 'obj/local/armeabi/objs/Prompt/Prompt.o' failedmake: *** [obj/local/armeabi/objs/Prompt/Prompt.o] Error 1
报错跟cygwin没有关系,其实就是在源码libavutil目录里找不到文件avconfig.h; 查看源码后的确没有...囧TT~
编辑一个放到libavutil目录里就解决了报错问题;avconfig.h内容如下:
/* Generated by ffconf */#ifndef AVUTIL_AVCONFIG_H#define AVUTIL_AVCONFIG_H#define AV_HAVE_BIGENDIAN 0#define AV_HAVE_FAST_UNALIGNED 0#endif /* AVUTIL_AVCONFIG_H */
编译完成后,运行,OK。