어제 새벽 작업 이후 내용을 추가합니다!!
컴파일된 libffmpeg.so 파일의 크기를 확인 못했었는데, 1KB로 표시되네요. 그리고, 원글을 제작한 개발자의 블로그에도 사용이 안된다고 나와 있습니다. static 라이브러리로 사용하라는데, 일단 저는 다른 개발자가 만들어 놓은 libffmpeg.so를 이용해서 테스트 중 입니다. 직접 컴파일하는 것은 일단 다른 것들부터 진행하고 나서 천천히 해보려고 합니다.
libffmpeg.so를 구할 수 있는 사이트는 아래와 같습니다. 밑에 download라고 되어 있는 링크를 사용하시기 바랍니다. 첨부 파일을 다운 받으셔도 됩니다.
http://odroid.foros-phpbb.com/t338-ffmpeg-compiled-with-android-ndk
Create a new project, make jni folder, then download and extract ffmpeg, rename ffmpeg folder to ffmpeg.
Make a new config.sh in ffmpeg, notice a bout PREBUILT path and PLATFORM:
#!/bin/bash PREBUILT=/home/abitno/Android/android-ndk-r4/build/prebuilt/linux-x86/arm-eabi-4.4.0 PLATFORM=/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"
Then change mode config.sh and run
chmod +x config.sh ./config.sh
When config is completed, open config.h, find:
#define restrict restrict
replace by
#define restrict
Open libavutil/libm.h, remove static keyword in all function declaration.
Open Makefile in libavcodec, libavfilter, libavformat, libavutil, libpostproc and libswscale and remove two lines:
include $(SUBDIR)../subdir.mak include $(SUBDIR)../config.mak
add new av.mk file in ffmpeg folder:
# LOCAL_PATH is one of libavutil, libavcodec, libavformat, or libswscale #include $(LOCAL_PATH)/../config-$(TARGET_ARCH).mak include $(LOCAL_PATH)/../config.mak OBJS := OBJS-yes := MMX-OBJS-yes := include $(LOCAL_PATH)/Makefile # collect objects OBJS-$(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-sign FFCFLAGS += -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)) else C_OBJS := $(OBJS) S_OBJS := endif C_FILES := $(patsubst %.o,%.c,$(C_OBJS)) S_FILES := $(patsubst %.o,%.S,$(S_OBJS)) FFFILES := $(sort $(S_FILES)) $(sort $(C_FILES))
Create Android.mk in jni folder:
include $(all-subdir-makefiles)
Create Android.mk in ffmpeg folder:
LOCAL_PATH := $(call my-dir) include $(CLEAR_VARS) LOCAL_STATIC_LIBRARIES := libavformat libavcodec libavutil libpostproc libswscale LOCAL_MODULE := ffmpeg include $(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.mk LOCAL_SRC_FILES := $(FFFILES) LOCAL_C_INCLUDES := \ $(LOCAL_PATH) \ $(LOCAL_PATH)/.. LOCAL_CFLAGS += $(FFCFLAGS) LOCAL_CFLAGS += -include "string.h" -Dipv6mr_interface=ipv6mr_ifindex LOCAL_LDLIBS := -lz LOCAL_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.mk LOCAL_SRC_FILES := $(FFFILES) LOCAL_C_INCLUDES := \ $(LOCAL_PATH) \ $(LOCAL_PATH)/.. LOCAL_CFLAGS += $(FFCFLAGS) LOCAL_LDLIBS := -lz LOCAL_STATIC_LIBRARIES := $(FFLIBS) LOCAL_MODULE := $(FFNAME) include $(BUILD_STATIC_LIBRARY)
libavfilter, libavutil, libpostproc and libswscale / Android.mk
LOCAL_PATH := $(call my-dir) include $(CLEAR_VARS) include $(LOCAL_PATH)/../av.mk LOCAL_SRC_FILES := $(FFFILES) LOCAL_C_INCLUDES := \ $(LOCAL_PATH) \ $(LOCAL_PATH)/.. LOCAL_CFLAGS += $(FFCFLAGS) LOCAL_STATIC_LIBRARIES := $(FFLIBS) LOCAL_MODULE := $(FFNAME) include $(BUILD_STATIC_LIBRARY)
now, just go to jni folder and type ndk-build, then you will have ffmpeg.so
Source: http://abitno.me/compile-ffmpeg-android-ndk
Edit: if you need a reference:
http://rockplayer.freecoder.org/download/rockplayer_ffmpeg.zip
If you have some error messages about assembler, try to add this line to Android.mk LOCAL_ARM_MODE := arm
libffmpeg.so for Android (5) | 2011.12.14 |
---|---|
간단하고 명료한 FFMPEG 샘플 코드 (0) | 2011.09.23 |
FFMpeg for Android #2 (28) | 2011.04.19 |
FFMpeg for Android #1 (0) | 2011.04.15 |
FFmpeg 기초 예제 (2) | 2011.02.24 |