2015년 1월 26일 월요일

android ffmpeg build

1. make android toolchain
$ /cygdrive/c/android-ndk-r10d/build/tools/make-standalone-toolchain.sh --platform=android-18 --install-dir=c:/my-android-toolchain-18 --arch=arm --system=windows-x86_64

2. ffmpeg configure
./configure --target-os=linux --arch=arm --enable-cross-compile --cc=/cygdrive/c/my-android-toolchain-18/bin/arm-linux-androideabi-gcc --cross-prefix=/cygdrive/c/my-android-toolchain-18/bin/arm-linux-androideabi- --extra-cflags="-marm -march=armv7-a -mfloat-abi=softfp -mfpu=neon" --extra-ldflags="-Wl,--fix-cortex-a8" --disable-doc --disable-ffmpeg --disable-ffplay --disable-ffprobe --disable-ffserver --disable-avdevice --disable-network --disable-devices --disable-filters --prefix=../ffmpeg-build

make
make install

// make 후 아래 에러 발생시 config.h 수정
$ make
CC      libavfilter/allfilters.o
In file included from ./libavutil/common.h:83:0,
                 from ./libavutil/avutil.h:289,
                 from libavfilter/avfilter.h:39,
                 from libavfilter/allfilters.c:22:
./config.h:9:18: warning: missing terminating " character [enabled by default]
 (GCC)"e CC_IDENT "gcc 4.8
                  ^
./config.h:10:7: warning: missing terminating " character [enabled by default]
 #define av_restrict restrict
       ^
./config.h:10:2: error: missing terminating " character
 #define av_restrict restrict
  ^
In file included from ./libavutil/intmath.h:30:0,
                 from ./libavutil/common.h:84,
                 from ./libavutil/avutil.h:289,
                 from libavfilter/avfilter.h:39,
                 from libavfilter/allfilters.c:22:
./libavutil/arm/intmath.h:34:1: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'static'
 static av_always_inline av_const unsigned av_clip_uint8_arm(int a)
 ^
common.mak:49: recipe for target 'libavfilter/allfilters.o' failed
make: *** [libavfilter/allfilters.o] Error 1

config.h 에서
#define CC_IDENT "gcc 4.8
 (GCC)"

#define CC_IDENT "gcc 4.8 (GCC)"
로 수정

3. modify Android.mk

LOCAL_PATH := $(call my-dir)

include $(CLEAR_VARS)
LOCAL_MODULE := avcodec
LOCAL_SRC_FILES := $(LOCAL_PATH)/libs/libavcodec.a
LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/include
include $(PREBUILT_STATIC_LIBRARY)

include $(CLEAR_VARS)
LOCAL_MODULE := avformat
LOCAL_SRC_FILES := $(LOCAL_PATH)/libs/libavformat.a
LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/include
include $(PREBUILT_STATIC_LIBRARY)

include $(CLEAR_VARS)
LOCAL_MODULE := swscale
LOCAL_SRC_FILES := $(LOCAL_PATH)/libs/libswscale.a
LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/include
include $(PREBUILT_STATIC_LIBRARY)

include $(CLEAR_VARS)
LOCAL_MODULE := avutil
LOCAL_SRC_FILES := $(LOCAL_PATH)/libs/libavutil.a
LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/include
include $(PREBUILT_STATIC_LIBRARY)

include $(CLEAR_VARS)
LOCAL_MODULE := swresample
LOCAL_SRC_FILES := $(LOCAL_PATH)/libs/libswresample.a
LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/include
include $(PREBUILT_STATIC_LIBRARY)

include $(CLEAR_VARS)

LOCAL_MODULE    := DXMediaPlayer
LOCAL_SRC_FILES := com_example_dxmediaplayertest_DXMediaPlayer.cpp \
  DXMediaPlayerCtrl.cpp

LOCAL_LDLIBS := -llog -lz -ljnigraphics -landroid

LOCAL_STATIC_LIBRARIES := avformat avcodec avutil swscale swresample    => order must be kept !!!

LOCAL_CFLAGS := -DANDROID -D__STDC_CONSTANT_MACROS
LOCAL_CPPFLAGS := -DANDROID -D__STDC_CONSTANT_MACROS

include $(BUILD_SHARED_LIBRARY)

댓글 2개:

  1. 안녕하세요 포스팅 잘보고 있습니다. ffmpeg-2.5.3 소스코드로 우분투에서 따라했더니 큰 에러 발생 없이 빌드가 잘되네요 감사합니다^^

    답글삭제
  2. 안드로이드에 올리는 중, ndk build에서 계속 아래와 같은 에러가 나서 문의 드립니다 ㅠ

    root@asm-VirtualBox:/home/asm/Share/MoblieAtom/jni# ndk-build
    [armeabi] Compile thumb : atom264-jni <= atom264-jni.c
    In file included from /home/asm/Share/MoblieAtom/jni/atom264-jni.h:4:0,
    from /home/asm/Share/MoblieAtom/jni/atom264-jni.c:6:
    /home/asm/android-ndk-r9d/platforms/android-9/arch-arm/usr/include/jni.h:235:70: error: expected ':', ',', ';', '}' or '__attribute__' before '__NDK_FPABI__'
    /home/asm/android-ndk-r9d/platforms/android-9/arch-arm/usr/include/jni.h:1147:24: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'JNI_OnLoad'
    /home/asm/android-ndk-r9d/platforms/android-9/arch-arm/usr/include/jni.h:1148:24: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'JNI_OnUnload'
    In file included from /home/asm/Share/MoblieAtom/jni/atom264-jni.c:6:0:
    /home/asm/Share/MoblieAtom/jni/atom264-jni.h:10:28: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'Java_com_mobileatom_Atomlib_run'
    /home/asm/Share/MoblieAtom/jni/atom264-jni.c:27:28: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'Java_com_mobileatom_Atomlib_run'
    make: *** [/home/asm/Share/MoblieAtom/obj/local/armeabi/objs/atom264-jni/atom264-jni.o] Error 1

    혹시 이런 문제가 발생하셨거나 해결방법을 아시는지요? ㅠ

    답글삭제