一,获取x264源码
使用git下载:
git clone http://git.videolan.org/git/x264.git
官网下载:
http://www.videolan.org/developers/x264.html
历史版本:
ftp://ftp.videolan.org/pub/videolan/x264/snapshots/
二, ubuntu16.04 + ndk-r10e环境
官网下载:
Windows 32-bit android-ndk-r10e-windows-x86.exe
Windows 64-bit android-ndk-r10e-windows-x86_64.exe
Mac OS X 64-bit android-ndk-r10e-darwin-x86_64.bin
Linux 32-bit (x86) android-ndk-r10e-linux-x86.bin
Linux 64-bit (x86) android-ndk-r10e-linux-x86_64.bin
百度网盘下载:
链接:https://pan.baidu.com/s/1cOMfj_TlKosuoK_zxJYE8A 密码:ctv3
三,编译脚本
如果是编译动态库,先进入到x264目录,修改configure文件。定位到 1500行
else echo "SOSUFFIX=so" >> config.mak
echo "SONAME=libx264.so.$API"
这几行,将"libx264.so.$API"替换为"libx264.so",文件名中就不要版本了
在源码根目录下创建脚本文件 build_android.sh, 内容如下:
#!/bin/bash
if [ -z "$ANDROID_NDK" ]; then
echo "You must define ANDROID_NDK before starting."
echo "They must point to your NDK directories.\n"
exit 1
fi
# Detect OS
OS=`uname`
HOST_ARCH=`uname -m`
export CCACHE=; type ccache >/dev/null 2>&1 && export CCACHE=ccache
if [ $OS == 'Linux' ]; then
export HOST_SYSTEM=linux-$HOST_ARCH
elif [ $OS == 'Darwin' ]; then
export HOST_SYSTEM=darwin-$HOST_ARCH
fi
SOURCE=`pwd`
PREFIX=$SOURCE/build/android
SYSROOT=$ANDROID_NDK/platforms/android-14/arch-arm
CROSS_PREFIX=$ANDROID_NDK/toolchains/arm-linux-androideabi-4.8/prebuilt/$HOST_SYSTEM/bin/arm-linux-androideabi-
EXTRA_CFLAGS="-march=armv7-a -mfloat-abi=softfp -mfpu=neon -D__ARM_ARCH_7__ -D__ARM_ARCH_7A__"
EXTRA_LDFLAGS="-nostdlib"
./configure --prefix=$PREFIX \
--cross-prefix=$CROSS_PREFIX \
--extra-cflags="$EXTRA_CFLAGS" \
--extra-ldflags="$EXTRA_LDFLAGS" \
--enable-pic \
--enable-static \
--enable-strip \
--disable-cli \
--host=arm-linux \
--sysroot=$SYSROOT
make clean
make STRIP= -j4 install || exit 1
ANDROID_NDK为NDK所在目录,注意几个黑体变量的值
然后修改build_android_arm.sh文件的权限:
sudo chmod a+x build_android.sh
并执行:
./build_android.sh
网友评论