2014년 4월 3일 목요일

android용 ffmpeg shared library만들때

생성되는 라이브러리 이름이 libxxxx.so.<version> 라는 형식으로 생성되는경우
이는 안드로이드 빌드 시스템과 호환이 안된다.
아래와 같이 configure 파일의 부분을 찾아 바꿔줘야 함


SLIBNAME_WITH_MAJOR='$(SLIBNAME).$(LIBMAJOR)'
LIB_INSTALL_EXTRA_CMD='$$(RANLIB) "$(LIBDIR)/$(LIBNAME)"'
SLIB_INSTALL_NAME='$(SLIBNAME_WITH_VERSION)'
SLIB_INSTALL_LINKS='$(SLIBNAME_WITH_MAJOR) $(SLIBNAME)'

이것을

SLIBNAME_WITH_MAJOR='$(SLIBPREF)$(FULLNAME)-$(LIBMAJOR)$(SLIBSUF)'
LIB_INSTALL_EXTRA_CMD='$$(RANLIB) "$(LIBDIR)/$(LIBNAME)"'
SLIB_INSTALL_NAME='$(SLIBNAME_WITH_MAJOR)'
SLIB_INSTALL_LINKS='$(SLIBNAME)'

이렇게


android.mk에는 아래처럼 추가해주고

LOCAL_PATH := $(call my-dir)

# --------------------------------------------------------------------------------------------------------
include $(CLEAR_VARS)
LOCAL_MODULE := libavcodec
LOCAL_SRC_FILES := ./ffmpeg2.0.1/armv7-a/lib/libavcodec-55.so
include $(PREBUILT_SHARED_LIBRARY)

# --------------------------------------------------------------------------------------------------------
include $(CLEAR_VARS)
LOCAL_MODULE := libavformat
LOCAL_SRC_FILES := ./ffmpeg2.0.1/armv7-a/lib/libavformat-55.so
include $(PREBUILT_SHARED_LIBRARY)

# --------------------------------------------------------------------------------------------------------
include $(CLEAR_VARS)
LOCAL_MODULE := libswresample
LOCAL_SRC_FILES := ./ffmpeg2.0.1/armv7-a/lib/libswresample-0.so
include $(PREBUILT_SHARED_LIBRARY)

# --------------------------------------------------------------------------------------------------------
include $(CLEAR_VARS)
LOCAL_MODULE := libswscale
LOCAL_SRC_FILES := ./ffmpeg2.0.1/armv7-a/lib/libswscale-2.so
include $(PREBUILT_SHARED_LIBRARY)

# --------------------------------------------------------------------------------------------------------
include $(CLEAR_VARS)
LOCAL_MODULE := libavfilter
LOCAL_SRC_FILES := ./ffmpeg2.0.1/armv7-a/lib/libavfilter-3.so
include $(PREBUILT_SHARED_LIBRARY)

# --------------------------------------------------------------------------------------------------------
include $(CLEAR_VARS)
LOCAL_MODULE := libavresample
LOCAL_SRC_FILES := ./ffmpeg2.0.1/armv7-a/lib/libavresample-1.so
include $(PREBUILT_SHARED_LIBRARY)

# --------------------------------------------------------------------------------------------------------
include $(CLEAR_VARS)
LOCAL_MODULE := libavutil
LOCAL_SRC_FILES := ./ffmpeg2.0.1/armv7-a/lib/libavutil-52.so
include $(PREBUILT_SHARED_LIBRARY)


# --------------------------------------------------------------------------------------------------------
include $(CLEAR_VARS)

LOCAL_MODULE    := MyNativeModuleName


LOCAL_CFLAGS := .....
LOCAL_CPPFLAGS := .....

LOCAL_C_INCLUDES :.....
LOCAL_SRC_FILES :.....


LOCAL_LDLIBS := .....
LOCAL_SHARED_LIBRARIES := libavcodec libavformat libswscale libavutil libswresample libavfilter libavresample libavutil


java쪽에서 아래와 같이  dependency에 순서에 맞게 라이브러리를 로딩합니다.

static
{
LOG.d(TAG, "Build.CPU_ABI : " + Build.CPU_ABI);

        System.loadLibrary("avutil-52");
        System.loadLibrary("avcodec-55");
        System.loadLibrary("avformat-55");
        System.loadLibrary("swresample-0");
        System.loadLibrary("swscale-2");
        System.loadLibrary("avresample-1");
        System.loadLibrary("avfilter-3");
        System.loadLibrary("MyNativeModuleName");

}


댓글 없음:

댓글 쓰기