六个彩香港网上投注站:用Android NDK编译FFmpeg

来源:百度文库 编辑:中财网 时间:2024/04/29 21:16:55

A Bit? No!!!

用Android NDK编译FFmpeg

POSTED AT: 2010-07-24 06:38:52 UTC | POSTED IN: Android | 70 COMMENTS

Android内置的编解码器实在太少,于是我们需要FFmpeg。Android提供了NDK,为我们使用FFmpeg这种C语言代码提供了方便。

不过为了用NDK编译FFmpeg,还真的花费了不少时间,也得到了很多人的帮助,最应该谢谢havlenapetr。我觉得我现在这些方法算是比较简洁的了--

下面就尽量詳細的说一下我是怎么在项目中使用FFmpeg的,但是基于我混乱的表达能力,有不明白的就问我。

你得了解JNI和Android NDK的基本用法,若觉得我的文章还不错,可以看之前写的JNI简单入门和Android NDK入门


首先创建一个标准的Android项目vPlayer

android create project -n vPlayer -t 8 -p vPlayer -k me.abitno.vplayer -a PlayerView

然后在vPlayer目录里

mkdir jni && cd jniwget http://ffmpeg.org/releases/ffmpeg-0.6.tar.bz2tar xf ffmpeg-0.6.tar.bz2 && mv ffmpeg-0.6 ffmpeg && cd ffmpeg

在ffmpeg下新建一个config.sh,内容如下,注意把PREBUILT和PLATFORM设置正确。另外里面有些参数你也可以自行调整,我主要是为了配置一个播放器而这样设置的。

#!/bin/bashPREBUILT=/home/abitno/Android/android-ndk-r4/build/prebuilt/linux-x86/arm-eabi-4.4.0PLATFORM=/home/abitno/Android/android-ndk-r4/build/platforms/android-8/arch-arm./configure --target-os=linux \--arch=arm \--enable-version3 \--enable-gpl \--enable-nonfree \--disable-stripping \--disable-ffmpeg \--disable-ffplay \--disable-ffserver \--disable-ffprobe \--disable-encoders \--disable-muxers \--disable-devices \--disable-protocols \--enable-protocol=file \--enable-avfilter \--disable-network \--disable-mpegaudio-hp \--disable-avdevice \--enable-cross-compile \--cc=$PREBUILT/bin/arm-eabi-gcc \--cross-prefix=$PREBUILT/bin/arm-eabi- \--nm=$PREBUILT/bin/arm-eabi-nm \--extra-cflags="-fPIC -DANDROID" \--disable-asm \--enable-neon \--enable-armv5te \--extra-ldflags="-Wl,-T,$PREBUILT/arm-eabi/lib/ldscripts/armelf.x -Wl,-rpath-link=$PLATFORM/usr/lib -L$PLATFORM/usr/lib -nostdlib $PREBUILT/lib/gcc/arm-eabi/4.4.0/crtbegin.o $PREBUILT/lib/gcc/arm-eabi/4.4.0/crtend.o -lc -lm -ldl"

运行config.sh开始configure

chmod +x config.sh./config.sh

configure完成后,编辑刚刚生成的config.h,找到这句

#define restrict restrict

Android的GCC不支持restrict关键字,于是修改成下面这样

#define restrict

编辑libavutil/libm.h,把其中的static方法都删除。

分别修改libavcodec、libavfilter、libavformat、libavutil、libpostproc和libswscale下的Makefile,把下面两句删除

include $(SUBDIR)../subdir.makinclude $(SUBDIR)../config.mak

在ffmpeg下添加一个文件av.mk,内容如下

# LOCAL_PATH is one of libavutil, libavcodec, libavformat, or libswscale#include $(LOCAL_PATH)/../config-$(TARGET_ARCH).makinclude $(LOCAL_PATH)/../config.makOBJS :=OBJS-yes :=MMX-OBJS-yes :=include $(LOCAL_PATH)/Makefile# collect objectsOBJS-$(HAVE_MMX) += $(MMX-OBJS-yes)OBJS += $(OBJS-yes)FFNAME := lib$(NAME)FFLIBS := $(foreach,NAME,$(FFLIBS),lib$(NAME))FFCFLAGS  = -DHAVE_AV_CONFIG_H -Wno-sign-compare -Wno-switch -Wno-pointer-signFFCFLAGS += -DTARGET_CONFIG=\"config-$(TARGET_ARCH).h\"ALL_S_FILES := $(wildcard $(LOCAL_PATH)/$(TARGET_ARCH)/*.S)ALL_S_FILES := $(addprefix $(TARGET_ARCH)/, $(notdir $(ALL_S_FILES)))ifneq ($(ALL_S_FILES),)ALL_S_OBJS := $(patsubst %.S,%.o,$(ALL_S_FILES))C_OBJS := $(filter-out $(ALL_S_OBJS),$(OBJS))S_OBJS := $(filter $(ALL_S_OBJS),$(OBJS))elseC_OBJS := $(OBJS)S_OBJS :=endifC_FILES := $(patsubst %.o,%.c,$(C_OBJS))S_FILES := $(patsubst %.o,%.S,$(S_OBJS))FFFILES := $(sort $(S_FILES)) $(sort $(C_FILES))

接下来要添加一系列的Android.mk,在jni根目录下的内容如下

include $(all-subdir-makefiles)

在ffmpeg目录下,Android.mk

LOCAL_PATH := $(call my-dir)include $(CLEAR_VARS)LOCAL_STATIC_LIBRARIES := libavformat libavcodec libavutil libpostproc libswscaleLOCAL_MODULE := ffmpeginclude $(BUILD_SHARED_LIBRARY)include $(call all-makefiles-under,$(LOCAL_PATH))

libavformat/Android.mk

LOCAL_PATH := $(call my-dir)include $(CLEAR_VARS)include $(LOCAL_PATH)/../av.mkLOCAL_SRC_FILES := $(FFFILES)LOCAL_C_INCLUDES :=\$(LOCAL_PATH)\$(LOCAL_PATH)/..LOCAL_CFLAGS += $(FFCFLAGS)LOCAL_CFLAGS += -include "string.h" -Dipv6mr_interface=ipv6mr_ifindexLOCAL_LDLIBS := -lzLOCAL_STATIC_LIBRARIES := $(FFLIBS)LOCAL_MODULE := $(FFNAME)include $(BUILD_STATIC_LIBRARY)

libavcodec/Android.mk

LOCAL_PATH := $(call my-dir)include $(CLEAR_VARS)include $(LOCAL_PATH)/../av.mkLOCAL_SRC_FILES := $(FFFILES)LOCAL_C_INCLUDES :=\$(LOCAL_PATH)\$(LOCAL_PATH)/..LOCAL_CFLAGS += $(FFCFLAGS)LOCAL_LDLIBS := -lzLOCAL_STATIC_LIBRARIES := $(FFLIBS)LOCAL_MODULE := $(FFNAME)include $(BUILD_STATIC_LIBRARY)

libavfilter、libavutil、libpostproc和libswscale下的Android.mk内容如下

LOCAL_PATH := $(call my-dir)include $(CLEAR_VARS)include $(LOCAL_PATH)/../av.mkLOCAL_SRC_FILES := $(FFFILES)LOCAL_C_INCLUDES :=\$(LOCAL_PATH)\$(LOCAL_PATH)/..LOCAL_CFLAGS += $(FFCFLAGS)LOCAL_STATIC_LIBRARIES := $(FFLIBS)LOCAL_MODULE := $(FFNAME)include $(BUILD_STATIC_LIBRARY)

最外层的jni/Android.mk和jni/ffmpeg/Android.mk我只是随便这样写的,你应该根据自己的需求改写。

最后运行ndk-build,经过漫长的等待就编译完成了。至于具体怎么应用可能以后会写,我变得太懒了。。。


我已经尽最大努力写明白了,希望大家努力啊,一个全功能的解码器或者只是播放器还是很有必要的。

更新:想偷情的可以看这个在Android NDK中使用libffmpeg.so

本文基于 署名-非商业性使用-禁止演绎 2.5 中国大陆 发布

TAGS:Android,FFmpeg,NDK 真的有人喜欢我的博客啊 混乱中

70 COMMENTS >>LEAVE<<

  1. >>REPLY<< ABitNo on 2010-07-24 at 06:33

    现在可以了评论了吗?

  2. >>REPLY<< tmdab123 on 2010-07-24 at 06:45

    可以评论,嘿嘿

  3. >>REPLY<< young001 on 2010-07-25 at 11:35

    上姐姐图,我等

  4. >>REPLY<< ABitNo on 2010-07-25 at 11:49 @young001

    你等她做我老婆之后吧。。。

  5. >>REPLY<< imcaptor on 2010-08-12 at 06:12

    很好,编译成功了,只是有点笔误,执行config.sh,不是config.h

  6. >>REPLY<< ABitNo on 2010-08-12 at 06:15 @imcaptor

    已经更正,谢谢

  7. >>REPLY<< PHIL on 2010-08-12 at 12:29

    請問Android NDK编译FFmpeg完成
    Android就可以幫放WMA嗎?

  8. >>REPLY<< ABitNo on 2010-08-12 at 12:30 @PHIL

    不是啊,这个要自己写播放器程序,我现在在写。。。

  9. >>REPLY<< bit_eric on 2010-08-12 at 15:41

    请问编译完成后,怎么调用呢?随便举一个例子,MP4好了

  10. >>REPLY<< ABitNo on 2010-08-12 at 15:43 @bit_eric

    要自己写代码的啊。。。

    这又不是一个android程序

  11. >>REPLY<< bit_eric on 2010-08-12 at 17:06

    厄。。 能提供个例子或者资料吗 最近在苦恼如何在android上添加解码器的问题。。

  12. >>REPLY<< imcaptor on 2010-08-16 at 05:36

    编译出来的libffmpeg.so有多大?
    我的怎么只有1599个字节,有问题吧?

  13. >>REPLY<< ruysay on 2010-08-19 at 02:49

    請問一下,libffbmpeg.so編譯出來後,
    要如何調用ffmpeg呢?
    以下提出我的想法,不知道是否正確。
    我的想法是:
    在android src建立一個ffmpeg_JNI.java,接著透過JDK產生.class 以及abc_efg_ffmpeg_JNI.h 接著把他複製到project下的jni。
    此時jni目錄下應該會有:abc_efg_ffmpeg_JNI.c&h,還有一個ffmpeg目錄&Android.mk。
    我想請教版主一下,到目前為止Android.mk是針對產生libffmpeg.so所做的編輯,如果要讓abc_efg_ffmpeg_JNI.c也引用到ffmpeg中的函式的話,Android.mk應該如何修改呢?

  14. >>REPLY<< xsun33 on 2010-08-24 at 02:23

    你好:
    我按照你说的方法进行编译,第一步config.sh的时候就出现错误如下:
    ./config.sh: line 6: ./configure: Permission denied

    请博主帮我看看。

  15. >>REPLY<< ABitNo on 2010-08-24 at 04:50 @xsun33

    chmod +x configure

  16. >>REPLY<< \(^o^)/~ on 2010-08-24 at 07:41

    你好我也做这方面的东西报了个错
    /jni/libcodec/../libjni/surfaceflinger_wrap.cpp
    这个文件我找了半天都没找到

  17. >>REPLY<< \(^o^)/~ on 2010-08-24 at 07:42

    希望加个Q请高手指点下258318946

  18. >>REPLY<< xsun33 on 2010-08-24 at 08:36

    你好;

    首先谢谢你的回复。按照你的提示,改正后编译,出现新的新的错误:/home/xsun33/soft/android/android-ndk-r4b/build/prebuilt/linux-x86/arm-eabi-4.4.0/bin/arm-eabi-gcc is unableto create an executable file.
    C compiler test failed.

    我进入到相应的目录下查看,发现里面有两个gcc:分别为arm-eabi-gcc和arm-eabi-gcc-4.4.0,我将config.sh中的--cc=$PREBUILT/bin/arm-eabi-gcc \
    修改为--cc=$PREBUILT/bin/arm-eabi-gcc-4.4.0 \

    运行,出现同样的错误:/home/xsun33/soft/android/android-ndk-r4b/build/prebuilt/linux-x86/arm-eabi-4.4.0/bin/arm-eabi-gcc-4.4.0 is unable to create anexecutable file.
    C compiler test failed.

    我对linux的config编译不是很明白,请博主再帮忙看一下这是什么原因?

  19. >>REPLY<< ABitNo on 2010-08-24 at 11:50 @xsun33

    兄弟啊,不是我不给你方法,你现在就算知道怎么做你也不知道为什么还是会有更多问题,你还是先学点基本的知识才行。

  20. >>REPLY<< ABitNo on 2010-08-24 at 11:50 @\(^o^)/~

    哪里说有这个文件了?

  21. >>REPLY<< xsun33 on 2010-08-24 at 11:54

    你好:
    那我应该看哪些方面的基本知识呢?你可以给指导一下吗?因为毕设是这方面的,所以比较着急。自己对这方面又不是很熟悉。你给指导一下。

  22. >>REPLY<< ABitNo on 2010-08-24 at 11:58 @xsun33

    我只是很不可思议,你一点都不了解这东西,你还做毕设。到最后做完了你还是不了解这东西。。。

    你现在应该查找下出现这个错误的位置,然后解决它。别告诉我出错的地方在哪都找不到

  23. >>REPLY<< xsun33 on 2010-08-24 at 12:05

    你好:
    在公司实习了几个月,接触了android,所以想在这上面搞些东西。没想到会这么困难。现在已经确定课题了,再改课题是不可能了。只能硬着头皮上了。那我自己在努力学习一下。

  24. >>REPLY<< Miguel on 2010-08-25 at 09:49

    Hi everybody!!
    Ihave make a simple program to use some ffmpeg functions, and now Idon't know how make Android.mk to refer ffmpeg. I've done somethinglike this:
    ------------------------------------
    TOP_LOCAL_PATH := $(call my-dir)

    include $(all-subdir-makefiles)

    LOCAL_PATH := $(TOP_LOCAL_PATH)

    include $(CLEAR_VARS)

    LOCAL_SHARED_LIBRARIES := ffmpeg

    LOCAL_MODULE := Hello-FFMpeg
    LOCAL_SRC_FILES := mi-programa.c

    LOCAL_C_INCLUDES := $(LOCAL_PATH)/ffmpeg-0.6

    include $(BUILD_SHARED_LIBRARY)
    --------------------------------------

    But when I compile it with ndk-build it says me:

    undefined reference to `avcodec_register_all'
    collect2: ld returned 1 exit status

    Can anybody help me?
    Thanks!!!!

  25. >>REPLY<< ABitNo on 2010-08-25 at 11:33 @Miguel

    if you comile ffmpeg use my Android.mk, then the libffmpeg.so is unusable. you will find it so small.

    at this time, you can try to build ffmpeg to a static library

  26. >>REPLY<< xsun33 on 2010-08-25 at 13:24

    你好:
    这两天一直上网查询有关资料。实在是没有办法解决了。还请你帮忙看看。我的config.err中报错如下:/home/xsun33/soft/android/android-ndk-r4b/build/prebuilt/linux-x86/arm-eabi-4.4.0/bin/../lib/gcc/arm-eabi/4.4.0/../../../../arm-eabi/bin/ld:cannot find -lc
    collect2: ld returned 1 exit status
    C compiler test failed.

    是不是表示没有找到libc.so 库?

    还有,我应该看些什么资料比较好?最近这两天正在看makfile文件详解,gcc编译命令,android.mk文件的编写。看这些可以吗?你给指导一下。谢谢了。

  27. >>REPLY<< ABitNo on 2010-08-26 at 02:37 @xsun33

    这个lc的问题我不清楚。。。

    你看这些就可以的

  28. >>REPLY<< \(^o^)/~ on 2010-08-26 at 02:43

    博主:Unable to access jarfile /usr/local/android-sdk/tools/lib/archquery.jar
    Exception in thread "main" java.lang.NoClassDefFoundError: com/android/prefs/And
    roidLocation$AndroidLocationException报这个类找不到是什么原因啊

  29. >>REPLY<< zqzhang on 2010-08-26 at 07:22

    请问楼主,库我都编译过了,但是在编译ffmpeg.c的时候,出那么多错是这么回事?谢谢

    Gdbserver : [arm-eabi-4.4.0] /cygdrive/f/workspace2/androidPlayer/libs/armeabi/gdbserver
    Gdbsetup : /cygdrive/f/workspace2/androidPlayer/libs/armeabi/gdb.setup
    Gdbsetup : + source directory /cygdrive/f/workspace2/androidPlayer/jni
    Compile thumb : ffmpeg_jni Compile thumb : ffmpeg_jni SharedLibrary : libffmpeg_jni.so
    /cygdrive/f/workspace2/androidPlayer/obj/local/armeabi/libavfilter.a(defaults.o):In function `avfilter_default_get_video_buffer':
    /cygdrive/f/workspace2/androidPlayer/jni/ffmpeg/libavfilter/defaults.c:52: undefined reference to `av_fill_image_linesizes'
    /cygdrive/f/workspace2/androidPlayer/jni/ffmpeg/libavfilter/defaults.c:57: undefined reference to `av_fill_image_pointers'
    /cygdrive/f/workspace2/androidPlayer/jni/ffmpeg/libavfilter/defaults.c:60: undefined reference to `av_fill_image_pointers'
    /cygdrive/f/workspace2/androidPlayer/obj/local/armeabi/libavcodec.a(bink.o): In function `decode_init':
    /cygdrive/f/workspace2/androidPlayer/jni/ffmpeg/libavcodec/bink.c:975: undefined reference to `av_check_image_size'
    /cygdrive/f/workspace2/androidPlayer/obj/local/armeabi/libavcodec.a(dnxhddec.o): In function `dnxhd_decode_frame':
    /cygdrive/f/workspace2/androidPlayer/jni/ffmpeg/libavcodec/dnxhddec.c:309: undefined reference to `av_check_image_size'
    /cygdrive/f/workspace2/androidPlayer/obj/local/armeabi/libavcodec.a(dpx.o): In function `decode_frame':
    /cygdrive/f/workspace2/androidPlayer/jni/ffmpeg/libavcodec/dpx.c:143: undefined reference to `av_check_image_size'
    /cygdrive/f/workspace2/androidPlayer/obj/local/armeabi/libavcodec.a(eacmv.o): In function `cmv_decode_frame':
    /cygdrive/f/workspace2/androidPlayer/jni/ffmpeg/libavcodec/eacmv.c:160: undefined reference to `av_check_image_size'
    /cygdrive/f/workspace2/androidPlayer/obj/local/armeabi/libavcodec.a(eamad.o): In function `decode_frame':
    /cygdrive/f/workspace2/androidPlayer/jni/ffmpeg/libavcodec/eamad.c:264: undefined reference to `av_check_image_size'
    /cygdrive/f/workspace2/androidPlayer/obj/local/armeabi/libavcodec.a(eatgv.o):/cygdrive/f/workspace2/androidPlayer/jni/ffmpeg/libavcodec/eatgv.c:279:more undefined references to `av_check_image_size' follow
    /cygdrive/f/workspace2/androidPlayer/obj/local/armeabi/libavcodec.a(imgconvert.o): In function `ff_fill_linesize':
    /cygdrive/f/workspace2/androidPlayer/jni/ffmpeg/libavcodec/imgconvert.c:504: undefined reference to `av_fill_image_linesizes'
    /cygdrive/f/workspace2/androidPlayer/obj/local/armeabi/libavcodec.a(imgconvert.o): In function `ff_fill_pointer':
    /cygdrive/f/workspace2/androidPlayer/jni/ffmpeg/libavcodec/imgconvert.c:510: undefined reference to `av_fill_image_pointers'
    /cygdrive/f/workspace2/androidPlayer/obj/local/armeabi/libavcodec.a(imgconvert.o): In function `avpicture_fill':
    /cygdrive/f/workspace2/androidPlayer/jni/ffmpeg/libavcodec/imgconvert.c:518: undefined reference to `av_check_image_size'
    /cygdrive/f/workspace2/androidPlayer/jni/ffmpeg/libavcodec/imgconvert.c:521: undefined reference to `av_fill_image_linesizes'
    /cygdrive/f/workspace2/androidPlayer/jni/ffmpeg/libavcodec/imgconvert.c:524: undefined reference to `av_fill_image_pointers'
    /cygdrive/f/workspace2/androidPlayer/obj/local/armeabi/libavcodec.a(imgconvert.o): In function `avpicture_get_size':
    /cygdrive/f/workspace2/androidPlayer/jni/ffmpeg/libavcodec/imgconvert.c:600: undefined reference to `av_check_image_size'
    /cygdrive/f/workspace2/androidPlayer/obj/local/armeabi/libavcodec.a(indeo3.o): In function `iv_decode_frame':
    /cygdrive/f/workspace2/androidPlayer/jni/ffmpeg/libavcodec/indeo3.c:999: undefined reference to `av_check_image_size'
    /cygdrive/f/workspace2/androidPlayer/obj/local/armeabi/libavcodec.a(kgv1dec.o): In function `decode_frame':
    /cygdrive/f/workspace2/androidPlayer/jni/ffmpeg/libavcodec/kgv1dec.c:54: undefined reference to `av_check_image_size'
    /cygdrive/f/workspace2/androidPlayer/obj/local/armeabi/libavcodec.a(mjpegdec.o): In function `ff_mjpeg_decode_sof':
    /cygdrive/f/workspace2/androidPlayer/jni/ffmpeg/libavcodec/mjpegdec.c:222: undefined reference to `av_check_image_size'
    /cygdrive/f/workspace2/androidPlayer/obj/local/armeabi/libavcodec.a(mpegvideo.o): In function `MPV_common_init':
    /cygdrive/f/workspace2/androidPlayer/jni/ffmpeg/libavcodec/mpegvideo.c:514: undefined reference to `av_check_image_size'
    /cygdrive/f/workspace2/androidPlayer/obj/local/armeabi/libavcodec.a(nuv.o):/cygdrive/f/workspace2/androidPlayer/jni/ffmpeg/libavcodec/nuv.c:115:more undefined references to `av_check_image_size' follow
    /cygdrive/f/workspace2/androidPlayer/obj/local/armeabi/libavcodec.a(utils.o): In function `avcodec_default_get_buffer':
    /cygdrive/f/workspace2/androidPlayer/jni/ffmpeg/libavcodec/utils.c:286: undefined reference to `av_fill_image_linesizes'
    /cygdrive/f/workspace2/androidPlayer/jni/ffmpeg/libavcodec/utils.c:296: undefined reference to `av_fill_image_pointers'
    /cygdrive/f/workspace2/androidPlayer/obj/local/armeabi/libavcodec.a(utils.o): In function `avcodec_open':
    /cygdrive/f/workspace2/androidPlayer/jni/ffmpeg/libavcodec/utils.c:490: undefined reference to `av_check_image_size'
    /cygdrive/f/workspace2/androidPlayer/obj/local/armeabi/libavcodec.a(utils.o): In function `avcodec_encode_video':
    /cygdrive/f/workspace2/androidPlayer/jni/ffmpeg/libavcodec/utils.c:557: undefined reference to `av_check_image_size'
    /cygdrive/f/workspace2/androidPlayer/obj/local/armeabi/libavcodec.a(utils.o): In function `avcodec_decode_video2':
    /cygdrive/f/workspace2/androidPlayer/jni/ffmpeg/libavcodec/utils.c:607: undefined reference to `av_check_image_size'
    /cygdrive/f/workspace2/androidPlayer/obj/local/armeabi/libavcodec.a(utils.o): In function `av_parse_video_frame_size':
    /cygdrive/f/workspace2/androidPlayer/jni/ffmpeg/libavcodec/utils.c:1099: undefined reference to `av_parse_video_size'
    /cygdrive/f/workspace2/androidPlayer/obj/local/armeabi/libavcodec.a(utils.o): In function `av_parse_video_frame_rate':
    /cygdrive/f/workspace2/androidPlayer/jni/ffmpeg/libavcodec/utils.c:1104: undefined reference to `av_parse_video_rate'
    /cygdrive/f/workspace2/androidPlayer/obj/local/armeabi/libavcodec.a(vp3.o): In function `theora_decode_header':
    /cygdrive/f/workspace2/androidPlayer/jni/ffmpeg/libavcodec/vp3.c:1984: undefined reference to `av_check_image_size'
    /cygdrive/f/workspace2/androidPlayer/obj/local/armeabi/libavcodec.a(vp8.o): In function `update_dimensions':
    /cygdrive/f/workspace2/androidPlayer/jni/ffmpeg/libavcodec/vp8.c:228: undefined reference to `av_check_image_size'
    /cygdrive/f/workspace2/androidPlayer/obj/local/armeabi/libavcodec.a(vqavideo.o): In function `vqa_decode_init':
    /cygdrive/f/workspace2/androidPlayer/jni/ffmpeg/libavcodec/vqavideo.c:151: undefined reference to `av_check_image_size'
    /cygdrive/f/workspace2/androidPlayer/obj/local/armeabi/libavcodec.a(xsubdec.o): In function `decode_frame':
    /cygdrive/f/workspace2/androidPlayer/jni/ffmpeg/libavcodec/xsubdec.c:80: undefined reference to `av_check_image_size'
    /cygdrive/f/workspace2/androidPlayer/obj/local/armeabi/libavcodec.a(yop.o): In function `yop_decode_init':
    /cygdrive/f/workspace2/androidPlayer/jni/ffmpeg/libavcodec/yop.c:88: undefined reference to `av_check_image_size'
    /cygdrive/f/workspace2/androidPlayer/obj/local/armeabi/libavcodec.a(aacsbr.o): In function `sbr_make_f_master':
    /cygdrive/f/workspace2/androidPlayer/jni/ffmpeg/libavcodec/aacsbr.c:418: undefined reference to `log2f'
    /cygdrive/f/workspace2/androidPlayer/jni/ffmpeg/libavcodec/aacsbr.c:446: undefined reference to `log2f'
    /cygdrive/f/workspace2/androidPlayer/obj/local/armeabi/libavcodec.a(aacsbr.o): In function `sbr_make_f_derived':
    /cygdrive/f/workspace2/androidPlayer/jni/ffmpeg/libavcodec/aacsbr.c:570: undefined reference to `log2f'
    /cygdrive/f/workspace2/androidPlayer/jni/ffmpeg/libavcodec/aacsbr.c:570: undefined reference to `log2f'
    /cygdrive/f/workspace2/androidPlayer/obj/local/armeabi/libavcodec.a(aaccoder.o): In function `coef2minsf':
    /cygdrive/f/workspace2/androidPlayer/jni/ffmpeg/libavcodec/aaccoder.c:520: undefined reference to `log2f'
    /cygdrive/f/workspace2/androidPlayer/obj/local/armeabi/libavcodec.a(aaccoder.o):/cygdrive/f/workspace2/androidPlayer/jni/ffmpeg/libavcodec/aaccoder.c:525:more undefined references to `log2f' follow
    /cygdrive/f/workspace2/androidPlayer/obj/local/armeabi/libavformat.a(oggparsedirac.o): In function `dirac_header':
    /cygdrive/f/workspace2/androidPlayer/jni/ffmpeg/libavformat/oggparsedirac.c:39:undefined reference to `ff_dirac_parse_sequence_header'
    /cygdrive/f/workspace2/androidPlayer/obj/local/armeabi/libavformat.a(utils.o): In function `parse_image_size':
    /cygdrive/f/workspace2/androidPlayer/jni/ffmpeg/libavformat/utils.c:3189: undefined reference to `av_parse_video_size'
    /cygdrive/f/workspace2/androidPlayer/obj/local/armeabi/libavformat.a(utils.o): In function `parse_frame_rate':
    /cygdrive/f/workspace2/androidPlayer/jni/ffmpeg/libavformat/utils.c:3195: undefined reference to `av_parse_video_rate'
    collect2: ld returned 1 exit status
    make: *** [/cygdrive/f/workspace2/androidPlayer/obj/local/armeabi/libffmpeg_jni.so] Error 1

  30. >>REPLY<< xsun33 on 2010-08-26 at 08:28

    你好:

    目前按照你的提示,已经成功生成了config.mak和config.h文件,上次提示找不到libc.so文件,但是我的NDK的指定目录下明明是存在的。实在没办法,就在设置ldflags参数时,把PLATFORM变量用绝对路径代替,没想到居然成功了。可是自己检查了一下,PLATFORM变量设置的没有错误阿?不知道为什么就是找不到libc.so
    虽然成功了,但是不知道什么原因。
    谢谢博主近期的帮忙。以后有问题还请多多指教。

  31. >>REPLY<< zqzhang on 2010-08-26 at 09:35 @xsun33

    可以知道你是这么使用这些 .a和.so的吗
    如何验证编译的是正确的呢

  32. >>REPLY<< xsun33 on 2010-08-26 at 11:26 @zqzhang

    你好:
    具体使用还没有用过,我也是刚刚接触这方面的知识。不过编译完成后.a和.so文件都得到了。具体怎么使用还得进一步研究。

  33. >>REPLY<< Miguel on 2010-08-26 at 11:46 @ABitNo

    Iwould know who you use the compiled ffmpeg library (libffmpeg.so) inyour proyects, because I soppose that you are compling it to use inyour own program, no?
    Thanks!!!!

  34. >>REPLY<< Eagle on 2010-08-28 at 08:41

    我生成的so也只有1599字节,这个对不对?我用nm查看里面的函数,里面居然没有,清楼主有时间的话指点一下。非常感谢!

  35. >>REPLY<< Eagle on 2010-08-28 at 08:42 @Eagle

    我生成的so也只有1599字节,这个对不对?我用nm查看里面的函数,里面居然没有,楼主有时间的话指点一下。非常感谢!

  36. >>REPLY<< Eagle on 2010-08-28 at 09:00 @ruysay

    您好,根据您的思想,您现在调用成功没?

  37. >>REPLY<< xsun33 on 2010-09-01 at 02:16 @zqzhang

    你好;
    不知道你研究出怎么使用这些静态库和动态库文件了吗?我在工程里面调用,始终找不到函数。

  38. >>REPLY<< xsun33 on 2010-09-01 at 02:19 @ABitNo

    你好:

    博主,你好。按照你的思路,编译生成了.a的静态库文件和libffmpeg.so的动态库文件,但是在Android的项目里怎样使用呢?我始终没有调用成功。这个libffmpeg.so动态库和其他5个.a的静态库文件之间是什么关系呢?我看了一下havlenapetr的源码,还是没有看明白。博主是否可以给解答一下。

  39. >>REPLY<< ck on 2010-09-05 at 14:49

    版主可以放編譯好的so下載檔嗎??
    因為看編譯似乎很複雜
    想直接調用

  40. >>REPLY<< szhairui on 2010-09-11 at 15:18

    最后那个“偷情“是“偷懒“的误笔吧?

  41. >>REPLY<< ABitNo on 2010-09-11 at 16:35 @szhairui

    =。=我。。。

  42. >>REPLY<< ohye on 2010-09-13 at 03:53

    为什么编译通过后的libffmpeg.so才1.6k大小?

  43. >>REPLY<< ohye on 2010-09-13 at 03:56

    为什么你的有3.94M呢,我也是按照你的方法就行的,我哪里出错了呢

  44. >>REPLY<< ABitNo on 2010-09-13 at 04:10 @ohye

    这篇文章写的方法还是有些问题的,不过大体就这样了,有时间我会再修改的,不过现在太多事,写篇这么长的文章还是很费时间的

  45. >>REPLY<< ohye on 2010-09-13 at 04:43

    我觉得应该是.MK文件没配置好,有结果 告诉大家

  46. >>REPLY<< ck on 2010-09-13 at 18:01

    我的也1.6k耶
    真奇怪

  47. >>REPLY<< caxton on 2010-09-14 at 11:53

    I have the same question that libffmpeg.so is only 1.6k :(
    Any suggestion is appreciative.

  48. >>REPLY<< test on 2010-09-20 at 05:09

    妈呀 感觉没什么错误
    但是生成的so是1.6K
    -_-

  49. >>REPLY<< mark on 2010-09-20 at 05:28 @ABitNo

    所以1.6k是不對的?
    看其他.a檔的size應該都對了..:(

  50. >>REPLY<< mark on 2010-09-24 at 09:46

    請問版大:

    使用avcodec_decode_video2()解完一禎frame之後
    如何將上面函式第二個參數AVFrame *picture轉成Android的物件去呈現呢?

    謝謝

  51. >>REPLY<< 路人甲 on 2010-10-08 at 09:40

    請問一下版大
    我想用ndk build x264
    可是他一直都 disable asm 跟 pthread
    請問版大有這方面的經驗可以請教嗎
    謝謝你

  52. >>REPLY<< guo on 2010-10-14 at 02:07

    请问这样打开neon指令了吗

  53. >>REPLY<< ziv cheung on 2010-10-17 at 06:27

    请问楼主
    Gdbserver : [arm-eabi-4.4.0] /home/izxy/ide/ndk/android-ndk-r4b/samples/hello-jni/libs/armeabi/gdbserver
    Gdbsetup : /home/izxy/ide/ndk/android-ndk-r4b/samples/hello-jni/libs/armeabi/gdb.setup
    Gdbsetup : + source directory /home/izxy/ide/ndk/android-ndk-r4b/samples/hello-jni/jni/ffmpeg/libpostproc
    Gdbsetup : + source directory /home/izxy/ide/ndk/android-ndk-r4b/samples/hello-jni/jni/ffmpeg/libpostproc
    Gdbsetup : + source directory /home/izxy/ide/ndk/android-ndk-r4b/samples/hello-jni/jni/ffmpeg/libpostproc
    Gdbsetup : + source directory /home/izxy/ide/ndk/android-ndk-r4b/samples/hello-jni/jni/ffmpeg/libpostproc
    Gdbsetup : + source directory /home/izxy/ide/ndk/android-ndk-r4b/samples/hello-jni/jni/ffmpeg/libpostproc
    Gdbsetup : + source directory /home/izxy/ide/ndk/android-ndk-r4b/samples/hello-jni/jni/ffmpeg/libpostproc
    make:*** No rule to make target`/home/izxy/ide/ndk/android-ndk-r4b/samples/hello-jni/obj/local/armeabi/libswscale.a',needed by`/home/izxy/ide/ndk/android-ndk-r4b/samples/hello-jni/obj/local/armeabi/libffmpeg.so'.Stop.
    请问这个怎么进行下去呢,谢谢!

  54. >>REPLY<< ziv cheung on 2010-10-20 at 06:18

    能幫幫忙嗎 謝謝了阿

  55. >>REPLY<< yuan tangfu on 2010-10-21 at 01:50

    博主你好,按照你的方法,已经编译成功,但是在实际应用时,视频解码很慢, 原因是生成的config.h并没有将ARM选项直1,并没有针对ARM的编译优化。当将ARM选项直1时,就会出现如下错误。希望博主给予帮助谢谢。
    Error: thumb conditional instruction not in IT block

  56. >>REPLY<< ziv cheung on 2010-10-21 at 03:39 @yuan tangfu

    你好 请问你编译大时候有没有遇到下面的问题阿
    Gdbserver : [arm-eabi-4.4.0] /home/izxy/ide/ndk/android-ndk-r4b/samples/hello-jni/libs/armeabi/gdbserver
    Gdbsetup : /home/izxy/ide/ndk/android-ndk-r4b/samples/hello-jni/libs/armeabi/gdb.setup
    Gdbsetup : + source directory /home/izxy/ide/ndk/android-ndk-r4b/samples/hello-jni/jni/ffmpeg/libpostproc
    Gdbsetup : + source directory /home/izxy/ide/ndk/android-ndk-r4b/samples/hello-jni/jni/ffmpeg/libpostproc
    Gdbsetup : + source directory /home/izxy/ide/ndk/android-ndk-r4b/samples/hello-jni/jni/ffmpeg/libpostproc
    Gdbsetup : + source directory /home/izxy/ide/ndk/android-ndk-r4b/samples/hello-jni/jni/ffmpeg/libpostproc
    Gdbsetup : + source directory /home/izxy/ide/ndk/android-ndk-r4b/samples/hello-jni/jni/ffmpeg/libpostproc
    Gdbsetup : + source directory /home/izxy/ide/ndk/android-ndk-r4b/samples/hello-jni/jni/ffmpeg/libpostproc
    make:*** No rule to make target`/home/izxy/ide/ndk/android-ndk-r4b/samples/hello-jni/obj/local/armeabi/libswscale.a',needed by`/home/izxy/ide/ndk/android-ndk-r4b/samples/hello-jni/obj/local/armeabi/libffmpeg.so'.Stop.
    请问怎么进行下去呢? 谢谢

  57. >>REPLY<< yuan tangfu on 2010-10-21 at 06:38 @ziv cheung

    libswscale 这个文件夹底下是不是没有配置mk文件。从libpostproc里面copy一个过来,就好了~

  58. >>REPLY<< yuan tangfu on 2010-10-21 at 06:42 @ziv cheung

    留个QQ号吧 276081463 一起研究~

  59. >>REPLY<< ziv cheung on 2010-10-21 at 07:23 @yuan tangfu

    好的 谢谢了 我加您了 但是加不了 what is your real name? 要不然您加我吧 izhangxueyong@hotmail.com 谢谢了

  60. >>REPLY<< ziv cheung on 2010-10-21 at 07:24

    听说rockplayer就是在ffmpeg上面优化的

  61. >>REPLY<< ziv cheung on 2010-10-22 at 02:39

    为什么编译出来只有1.6k啊,真是好事多磨阿,呵呵

  62. >>REPLY<< ziv cheung on 2010-10-22 at 06:21 @yuan tangfu

    还在吗 你编译出来是1.6k吗 这是肯定不可能的阿,请问应该怎么处理阿 谢谢

  63. >>REPLY<< yuan tangfu on 2010-10-22 at 06:47 @ziv cheung

    obj里面点开,你会发现有5个.a文件几十m呢

  64. >>REPLY<< yuan tangfu on 2010-10-22 at 08:12

    cpu怎么设置啊?

    /var/folders/MI/MIvT4itIFdmKpIGfIiuK5E+++TI/-Tmp-//cc2i3AWV.s:6449:Error: selected processor does not support `vld1.32 {d1[]},[r4,:32]'
    /var/folders/MI/MIvT4itIFdmKpIGfIiuK5E+++TI/-Tmp-//cc2i3AWV.s:6451: Error: selected processor does not support `veor d0,d0,d2'
    /var/folders/MI/MIvT4itIFdmKpIGfIiuK5E+++TI/-Tmp-//cc2i3AWV.s:6452:Error: selected FPU does not support instruction -- `vmul.f32 d0,d0,d1'
    /var/folders/MI/MIvT4itIFdmKpIGfIiuK5E+++TI/-Tmp-//cc2i3AWV.s:6453:Error: selected processor does not support `vst1.32 {d0},[r2,:64]!'
    /var/folders/MI/MIvT4itIFdmKpIGfIiuK5E+++TI/-Tmp-//cc2i3AWV.s:6602:Error: selected processor does not support `vld1.32 {d1[]},[r8,:32]'
    /var/folders/MI/MIvT4itIFdmKpIGfIiuK5E+++TI/-Tmp-//cc2i3AWV.s:6604:Error: selected FPU does not support instruction -- `vmul.f32 d0,d0,d1'
    /var/folders/MI/MIvT4itIFdmKpIGfIiuK5E+++TI/-Tmp-//cc2i3AWV.s:6605:Error: selected processor does not support `vst1.32 {d0},[r3,:64]!'
    /var/folders/MI/MIvT4itIFdmKpIGfIiuK5E+++TI/-Tmp-//cc2i3AWV.s:6770:Error: selected processor does not support `vld1.32{d2[],d3[]},[r9,:32]'
    /var/folders/MI/MIvT4itIFdmKpIGfIiuK5E+++TI/-Tmp-//cc2i3AWV.s:6785: Error: thumb conditional instruction not in IT block
    /var/folders/MI/MIvT4itIFdmKpIGfIiuK5E+++TI/-Tmp-//cc2i3AWV.s:6788: Error: thumb conditional instruction not in IT block
    /var/folders/MI/MIvT4itIFdmKpIGfIiuK5E+++TI/-Tmp-//cc2i3AWV.s:6791: Error: thumb conditional instruction not in IT block
    /var/folders/MI/MIvT4itIFdmKpIGfIiuK5E+++TI/-Tmp-//cc2i3AWV.s:6795: Error: selected processor does not support `veor q0,q0,q2'
    /var/folders/MI/MIvT4itIFdmKpIGfIiuK5E+++TI/-Tmp-//cc2i3AWV.s:6796:Error: selected FPU does not support instruction -- `vmul.f32 q0,q0,q1'
    /var/folders/MI/MIvT4itIFdmKpIGfIiuK5E+++TI/-Tmp-//cc2i3AWV.s:6797:Error: selected processor does not support `vst1.32 {q0},[r2,:128]!'
    /var/folders/MI/MIvT4itIFdmKpIGfIiuK5E+++TI/-Tmp-//cc2i3AWV.s:6951:Error: selected processor does not support `vld1.32{d2[],d3[]},[sl,:32]'
    /var/folders/MI/MIvT4itIFdmKpIGfIiuK5E+++TI/-Tmp-//cc2i3AWV.s:6953:Error: selected FPU does not support instruction -- `vmul.f32 q0,q0,q1'
    /var/folders/MI/MIvT4itIFdmKpIGfIiuK5E+++TI/-Tmp-//cc2i3AWV.s:6954:Error: selected processor does not support `vst1.32 {q0},[r3,:128]!'
    make: *** [/Users/tangfu/Develop/trunk/svn/3rd/ffmpeg4android/obj/local/armeabi-v7a/objs/avcodec/aac.o] Error 1

  65. >>REPLY<< mlianghua on 2010-11-03 at 08:01 @xsun33

    Not find the path of arm-eabi-gcc

  66. >>REPLY<< Sai on 2010-11-11 at 09:10

    我build出來也是1.6k >"

  67. >>REPLY<< zeusgalaxy on 2010-11-15 at 21:33 @Sai

    Modify the file ffmpeg/Android.mk as below should build you a complete libffmpeg.so library.

    ---------- cut here ------------------
    LOCAL_PATH := $(call my-dir)

    include $(CLEAR_VARS)

    LOCAL_C_INCLUDES += \
    $(LOCAL_PATH)

    LOCAL_SRC_FILES := \
    ffmpeg.c \
    cmdutils.c

    LOCAL_STATIC_LIBRARIES := libavformat libavcodec libavutil libpostproc libswscale

    LOCAL_MODULE := ffmpeg

    include $(BUILD_SHARED_LIBRARY)

    include $(call all-makefiles-under,$(LOCAL_PATH))
    ---------- cut here ------------------

    1. In ffmpeg directory, type command "make version.sh" to build the version.h file.

    2. type command "ndk-build -j8" to build libffmpeg.so

  68. >>REPLY<< Ricky on 2010-11-24 at 08:46

    /configure 后面把 --disable-muxers 参数去掉,编译不通过了???

    from /home/www/workspace/android_ffmpeg/jni/ffmpeg/libavformat/asfdec.c:26:
    /home/www/workspace/android_ffmpeg/jni/ffmpeg/libavformat/../libavcodec/dsputil.h:448:error: expected ';', ',' or ')' before 'v1'
    /home/www/workspace/android_ffmpeg/jni/ffmpeg/libavformat/../libavcodec/dsputil.h:452: error: expected ';' before 'void'
    /home/www/workspace/android_ffmpeg/jni/ffmpeg/libavformat/asfdec.c: In function 'asf_read_header':
    /home/www/workspace/android_ffmpeg/jni/ffmpeg/libavformat/asfdec.c:380: warning: 'AVPaletteControl' is deprecated
    make: *** [/home/www/workspace/android_ffmpeg/obj/local/armeabi/objs/ffmpeg/asfdec.o] 错误 1

  69. >>REPLY<< Bill on 2010-11-29 at 12:30

    你好 楼主
    我遇到了个问题:
    我使用NDK r4 crystax 编译 Hello-jni文件
    然而 我到make这一步 报错 ERROR 127
    然后就停止编译了
    请问这是什么情况?
    我以前使用r1的时候一切正常
    其他ndk命令也正常
    唯独到了ndk-build时出现错误
    如果楼主有什么想法 请发我邮箱
    谢谢

  70. >>REPLY<< 彭鹏 on 2010-12-06 at 08:54

    我打了ndk-build可为什么编译不了,说ndk-build command not found

LEAVE A RESPONSE