Android NDK编译FFmpeg可以采用cygwin方法来实现。
具体步骤:
首先是config脚本,编译ffmpeg之前必须得先configure一下,configure是一个shell脚本,根据命令行参数不同来裁剪模块,生成特定的config.h文件。
confiure脚本文件在ffmpeg目录里可以找到。
重新建立以个shell脚本文件config.sh,这个文件只是为了编译方便。
例子:
注意:
编写config脚本时候,其中的路径需要使用windows形式的路径,不能使用/cygwindriver/d/android 这种格式的路径。
1. 编译的准备条件:
编译环境: ubuntu-10.10
Android NDK: android-ndk-r6-linux-x86.tar.bz2.tar
ffmpeg版本: ffmpeg-0.8.1 (注意: 此处一定要使用旧版本, 如果使用最新版本的话编译比较麻烦, 经常出错)
2. 准备条件:
2.1 创建编译脚本 config.sh:
[java] view plaincopy
./configure \
--disable-static \
--enable-shared \
--enable-gpl \
--enable-version3 \
--enable-nonfree \
--disable-doc \
--disable-ffmpeg \
--disable-ffplay \
--disable-ffprobe \
--disable-ffserver \
--disable-avdevice \
--disable-avfilter \
--disable-postproc \
--enable-small \
--cross-prefix=/home/qhwanga/ndkdome/android-ndk-r6b/toolchains/arm-linux-androideabi-4.4.3/prebuilt/linux-x86/bin/arm-linux-androideabi- \
--enable-cross-compile \
--target-os=linux \
--extra-cflags='-I/home/qhwanga/ndkdome/android-r6b/platforms/android-9/arch-arm/usr/include' \
--extra-ldflags='-L/home/qhwanga/ndkdome/android-r6b/platforms/android-9/arch-arm/usr/lib -nostdlib' \
--arch=arm \
--disable-symver \
--disable-debug \
--disable-stripping \
sed -i 's/HAVE_LRINT 0/HAVE_LRINT 1/g' config.h
sed -i 's/HAVE_LRINTF 0/HAVE_LRINTF 1/g' config.h
sed -i 's/HAVE_ROUND 0/HAVE_ROUND 1/g' config.h
sed -i 's/HAVE_ROUNDF 0/HAVE_ROUNDF 1/g' config.h
sed -i 's/HAVE_TRUNC 0/HAVE_TRUNC 1/g' config.h
sed -i 's/HAVE_TRUNCF 0/HAVE_TRUNCF 1/g' config.h
注意: --enable-prefix , --extra-cflags, --extra-ldflags 路径需要根据个人的实际路径去配置.
2.2 创建Android.mk脚本:
[java] view plaincopy
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := ffmpeg
include $(LOCAL_PATH)/config.mak
LOCAL_CFLAGS := -DHAVE_AV_CONFIG_H -std=c99
AVUTIL_C_FILES = adler32.c \
aes.c \
audioconvert.c \
avstring.c \
base64.c \
cpu.c \
crc.c \
des.c \
error.c \
eval.c \
fifo.c \
file.c \
imgutils.c \
intfloat_readwrite.c \
inverse.c \
lfg.c \
lls.c \
log.c \
lzo.c \
mathematics.c \
md5.c \
mem.c \
dict.c \
opt.c \