(5)在当前目录下执行: make , make install
完成后,就可以在FFmpeg-Android的android-x264目录下生成头文件和静态库文件了,至此,x264编译完成。
(1)将压缩包解压缩到FFmpeg-Android的根目录下
(2)编写脚本,这里将配置和编译过程分成两个脚本来写,主要是配置脚本完成后,还要手动的去修改ffmpeg目录下的config.h文件
配置脚本:
#!/bin/bash
DEST=`pwd`/build/ffmpeg && rm -rf $DEST
SOURCE=`pwd`/ffmpeg
if [ -d ffmpeg ]; then
cd ffmpeg
else
echo "can not find ffmpeg source code"
exit 1
fi
if [ "$PIPESTATUS" != "0" ] ; then
echo "error in FFmpeg-Android.sh : 14 "
fi
TOOLCHAIN=/tmp/vplayer
SYSROOT=$TOOLCHAIN/sysroot/
$NDK_HOME/build/tools/make-standalone-toolchain.sh --platform=android-19 --install-dir=$TOOLCHAIN
export PATH=$TOOLCHAIN/bin:$PATH
export CC="arm-linux-androideabi-gcc"
export LD=arm-linux-androideabi-ld
export AR=arm-linux-androideabi-ar
#CFLAGS="-O3 -Wall -mthumb -pipe -fpic -fasm \
# -finline-limit=300 -ffast-math \
# -fstrict-aliasing \
# -fmodulo-sched -fmodulo-sched-allow-regmoves \
# -Wno-psabi -Wa,--noexecstack \
# -DANDROID -DNDEBUG"
CFLAGS="-Os -fPIC -marm"
FFMPEG_FLAGS="--target-os=linux \
--arch=arm \
--sysroot=$SYSROOT \
--enable-cross-compile \
--cross-prefix=arm-linux-androideabi- \
--enable-shared \
--enable-static \
--disable-symver \
--disable-doc \
--disable-ffplay \
--disable-ffmpeg \
--disable-ffprobe \
--disable-ffserver \
--disable-avdevice \
--disable-avfilter \
--disable-filters \
--disable-devices \
--disable-pthreads \
--disable-everything \
--enable-gpl \
--enable-muxers \
--enable-encoders \
--enable-protocols \
--enable-parsers \
--enable-demuxers \
--enable-decoders \
--enable-bsfs \
--enable-network \
--enable-swscale \
--enable-libx264 \
--enable-encoder=libx264 \
--enable-decoder=h264 \
--enable-muxer=h264 \
--enable-demuxer=h264 \
--disable-demuxer=sbg \
--disable-demuxer=dts \
--disable-parser=dca \
--disable-decoder=dca \
--extra-libs=-lx264 \
--enable-asm \
--enable-version3"
VERSION=armv7
cd $SOURCE
EXTRA_CFLAGS="-I../android-x264/include -march=armv7-a"
EXTRA_LDFLAGS="-L../android-x264/lib"
PREFIX="$DEST/$VERSION" && mkdir -p $PREFIX
FFMPEG_FLAGS="$FFMPEG_FLAGS --prefix=$PREFIX"
sh ./configure $FFMPEG_FLAGS --extra-cflags="$CFLAGS $EXTRA_CFLAGS" --extra-ldflags="$EXTRA_LDFLAGS" | tee $PREFIX/configuration.txt
if [ "$?" = "0" ] ; then
echo "./configure success in shell-script"
else
echo "./configure erroe in shell-script"
exit 1
fi
cp config.* $PREFIX