欢迎加入技术交流群
群号: 552340860
下面用到的脚本、静态库资料.
上一篇文章讲到FFmpeg默认的编译静态库中是没有音视频的编码器的,需要我们手动编译进FFmpeg,这篇文章就讲一样如何编译AAC音频编码器,主要还是对脚本的编写工作。
1、准备fdk-aac源文件
直接通过网络下载即可。
2、脚本文件编写
#!/bin/sh
CONFIGURE_FLAGS="--enable-static --with-pic=yes --disable-shared"
ARCHS="arm64 x86_64 i386 armv7"
# 源文件名
SOURCE="fdk-aac-0.1.6"
FAT="fdk-aac-ios"
SCRATCH="scratch"
# thin当前脚本下的自定义文件,用于接收编译后的头文件和静态库
THIN=`pwd`/"thin"
COMPILE="y"
LIPO="y"
if [ "$*" ]
then
if [ "$*" = "lipo" ]
then
# skip compile
COMPILE=
else
ARCHS="$*"
if [ $# -eq 1 ]
then
# skip lipo
LIPO=
fi
fi
fi
if [ "$COMPILE" ]
then
CWD=`pwd`
for ARCH in $ARCHS
do
echo "building $ARCH..."
mkdir -p "$SCRATCH/$ARCH"
cd "$SCRATCH/$ARCH"
CFLAGS="-arch $ARCH"
if [ "$ARCH" = "i386" -o "$ARCH" = "x86_64" ]
then
PLATFORM="iPhoneSimulator"
CPU=
if [ "$ARCH" = "x86_64" ]
then
CFLAGS="$CFLAGS -mios-simulator-version-min=7.0"
HOST="--host=x86_64-apple-darwin"
else
CFLAGS="$CFLAGS -mios-simulator-version-min=7.0"
HOST="--host=i386-apple-darwin"
fi
else
PLATFORM="iPhoneOS"
if [ $ARCH = arm64 ]
then
HOST="--host=aarch64-apple-darwin"
else
HOST="--host=arm-apple-darwin"
fi
CFLAGS="$CFLAGS -fembed-bitcode"
fi
XCRUN_SDK=`echo $PLATFORM | tr '[:upper:]' '[:lower:]'`
CC="xcrun -sdk $XCRUN_SDK clang -Wno-error=unused-command-line-argument-hard-error-in-future"
AS="$CWD/$SOURCE/extras/gas-preprocessor.pl $CC"
CXXFLAGS="$CFLAGS"
LDFLAGS="$CFLAGS"
$CWD/$SOURCE/configure \
$CONFIGURE_FLAGS \
$HOST \
$CPU \
CC="$CC" \
CXX="$CC" \
CPP="$CC -E" \
AS="$AS" \
CFLAGS="$CFLAGS" \
LDFLAGS="$LDFLAGS" \
CPPFLAGS="$CFLAGS" \
--prefix="$THIN/$ARCH"
make -j3 install
cd $CWD
done
fi
if [ "$LIPO" ]
then
echo "building fat binaries..."
mkdir -p $FAT/lib
set - $ARCHS
CWD=`pwd`
cd $THIN/$1/lib
for LIB in *.a
do
cd $CWD
lipo -create `find $THIN -name $LIB` -output $FAT/lib/$LIB
done
cd $CWD
cp -rf $THIN/$1/include $FAT
fi
和前面编译x264一样,脚本内容大致差不多,通过这个脚本编译即可。
本人编译好的fdk-aac静态库、脚本。
3、编译
进入当前目录,打开终端进行编译就行。
$ chmod +x build_fdk-aac_iOS_ptl.sh
$ ./build_fdk-aac_iOS_ptl.sh
如图编译后的目录结构:
fdk-aac.png
到这里就完成了对fdk-aac的编译。
网友评论