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)
~/ayer/jni/ffmpeg/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_LDLIBS := -lz
LOCAL_STATIC_LIBRARIES := $(FFLIBS)
LOCAL_MODULE := $(FFNAME)
include $(BUILD_STATIC_LIBRARY)
编写配置脚本:~/ayer/jni/ffmpeg/config.sh
注意其中的NDK路径,请修改成你系统中对应的安装路径
#!/bin/bash
source config_common.sh
PREBUILT=/home/huaguanglu/bysj/android-ndk-r8b/toolchains/arm-linux-androideabi-4.4.3/prebuilt/linux-x86
PLATFORM=/home/huaguanglu/bysj/android-ndk-r8b/platforms/android-9/arch-arm
NDK_ROOT=/home/huaguanglu/bysj/android-ndk-r8b
./configure --target-os=linux \
--arch=arm \
--extra-cflags="-I${NDK_ROOT}/platforms/android-9/arch-arm/usr/include -fPIC -DANDROID -std=c99" \
--disable-everything \
--enable-version3 \
--enable-gpl \
--enable-nonfree \
--disable-stripping \
--disable-ffmpeg \
--disable-ffplay \
--disable-ffserver \
--disable-ffprobe \
--disable-encoders \
--disable-muxers \
--disable-devices \
--disable-protocols \
--disable-network \
--disable-avdevice \
--disable-asm \
--enable-decoder=h264 \
--enable-swscale \
--enable-cross-compile \
--cc=$PREBUILT/bin/arm-linux-androideabi-gcc \
--cross-prefix=$PREBUILT/bin/arm-linux-androideabi- \
--strip=$PREBUILT/bin/arm-linux-androideabi-strip \
--extra-cflags="-fPIC -DANDROID" \
--extra-ldflags="-Wl,-T,$PREBUILT/arm-linux-androideabi/lib/ldscripts/armelf_linux_eabi.x -Wl,-rpath-link=$PLATFORM/usr/lib -L$PLATFORM/usr/lib -nostdlib $PREBUILT/lib/gcc/arm-linux-androideabi/4.4.3/crtbegin.o $PREBUILT/lib/gcc/arm-linux-androideabi/4.4.3/crtend.o -lc -lm -ldl"
终端输入命令:
chmod 755 config.sh
./config.sh
这时会在~/ayer/jni/ffmpeg目录下生成三个文件: config.h,config.mak,config.log。
我们需要修改config.h文件,将其中的
#define av_restrict restrict
修改成
#define av_restrict
修改ffmpeg代码,以便在NDK中编译通过
在libavfilter目录中的Makefile的末尾处多了 Clean 这个玩意儿 将其注释掉或者删掉。
修改~/ayer/jni/ffmpeg/libavutil/libm.h文件,将其中的所有static方法都注释掉
修改ffmpeg源码目录中的libavcodev,libavfilter,libavformat,libavutil,libpostproc,libswscale中的Makefile,将Makefile中的开头:include $(SUBDIR)../config.mak都注释掉。
进入目录:~/ayer