编译 x264
x264 是采用 GPL 授权的开源视频编码库,主要用于 H.264/MPEG-4 AVC 的视频编码,仅作为编码
器使用。
下载地址
http://download.videolan.org/pub/videolan/x264/snapshots/
https://www.videolan.org/developers/x264.html
git clone https://github.com/mirror/x264.git
在 x264 解压目录下创建编译脚本build_x264.sh:
#!/bin/bash
export NDK=/home/wang/ffmpeng/ndk/android-ndk-r20b # 这里需要替换成你本地的 NDK 路径,其他的不用修改
TOOLCHAIN=$NDK/toolchains/llvm/prebuilt/linux-x86_64
export API=21
function build_android
{
./configure \
--prefix=$PREFIX \
--disable-cli \
--enable-shared \
--enable-static \
--enable-pic \
--host=$my_host \
--cross-prefix=$CROSS_PREFIX \
--sysroot=$NDK/toolchains/llvm/prebuilt/linux-x86_64/sysroot \
make clean
make -j8
make install
}
#arm64-v8a
PREFIX=./android/arm64-v8a
my_host=aarch64-linux-android
export TARGET=aarch64-linux-android
export CC=$TOOLCHAIN/bin/$TARGET$API-clang
export CXX=$TOOLCHAIN/bin/$TARGET$API-clang++
CROSS_PREFIX=$TOOLCHAIN/bin/aarch64-linux-android-
build_android
#armeabi-v7a
PREFIX=./android/armeabi-v7a
my_host=armv7a-linux-android
export TARGET=armv7a-linux-androideabi
export CC=$TOOLCHAIN/bin/$TARGET$API-clang
export CXX=$TOOLCHAIN/bin/$TARGET$API-clang++
CROSS_PREFIX=$TOOLCHAIN/bin/arm-linux-androideabi-
build_android
修改脚本权限以及编译
chmod 777 build_x264.sh
./build_x264.sh
编译结果
动态库和静态库、头文件
fdk-aac编译
fdk-aac 是指:Fraunhofer FDK AAC 编解码器库,是一个开源软件库,用于编码和解码高级音频编码格式 AAC 的音频
下载地址
https://www.linuxfromscratch.org/blfs/view/svn/multimedia/fdk-aac.html
wget https://downloads.sourceforge.net/opencore-amr/fdk-aac-2.0.2.tar.gz
解压命令
tar -xzvf fdk-aac-2.0.2.tar.gz
在 fdk-aac 解压目录下创建编译脚本build_fdk_aac.sh:
#!/bin/bash
NDK=/root/workspace/android-ndk-r20b # 这里需要替换成你本地的 NDK 路径,其他的不用修改
HOST_TAG=linux-x86_64
TOOLCHAIN=$NDK/toolchains/llvm/prebuilt/$HOST_TAG
ANDROID_LIB_PATH="$(pwd)/android"
API=21
function build_android
{
echo "Build fdk-aac for android $CPU"
./configure \
--host=$HOST \
--disable-shared \
--enable-static \
--prefix="$ANDROID_LIB_PATH/$CPU" \
CPPFLAGS="-fPIC"
make clean
make -j8
make install
echo "Build fdk-aac for android $CPU completed"
}
# armeabi-v7a
CPU=armv7-a
HOST=arm-linux-android
export AR=$TOOLCHAIN/bin/arm-linux-androideabi-ar
export AS=$TOOLCHAIN/bin/arm-linux-androideabi-as
export LD=$TOOLCHAIN/bin/arm-linux-androideabi-ld
export RANLIB=$TOOLCHAIN/bin/arm-linux-androideabi-ranlib
export STRIP=$TOOLCHAIN/bin/arm-linux-androideabi-strip
export CC=$TOOLCHAIN/bin/armv7a-linux-androideabi$API-clang
export CXX=$TOOLCHAIN/bin/armv7a-linux-androideabi$API-clang++
build_android
# arm64-v8a
CPU=armv8-a
HOST=aarch64-linux-android
export AR=$TOOLCHAIN/bin/aarch64-linux-android-ar
export AS=$TOOLCHAIN/bin/aarch64-linux-android-as
export LD=$TOOLCHAIN/bin/aarch64-linux-android-ld
export RANLIB=$TOOLCHAIN/bin/aarch64-linux-android-ranlib
export STRIP=$TOOLCHAIN/bin/aarch64-linux-android-strip
export CC=$TOOLCHAIN/bin/aarch64-linux-android$API-clang
export CXX=$TOOLCHAIN/bin/aarch64-linux-android$API-clang++
build_android
修改脚本权限以及编译
chmod 777 build_x264.sh
chmod 777 configure
./build_x264.sh
编译结果
动态库和静态库、头文件
fdk-aac、x264脚本下载