網(wǎng)上看了許多的微博,關(guān)于這個方面的很少消别,所以想寫點傻瓜式的抛蚤,新手一看就會,還不要那么麻煩妖啥。方便研究底層的同學(xué)霉颠。
先下載FFmpeg和x264都會用到的腳本
下載gas-pregprcessor?將文件放到/usr/local/bin的文件夾下
首先是編譯下x264
1 先去官網(wǎng)下載x264解碼器源碼 解壓?
將腳本 和 源碼放在同級目錄下
終端執(zhí)行 ./build-x264.sh 腳本即可?
3 ?編譯libaac?參考這個這個大神的微博 執(zhí)行腳本文件?注意
FFmpeg執(zhí)行腳本 將編譯好的
#!/bin/sh
# directories
SOURCE="ffmpeg-3.2"
FAT="FFmpeg-iOS"
SCRATCH="scratch"
# must be an absolute path
THIN=`pwd`/"thin"
# absolute path to x264 library
X264=`pwd`/fat-x264
FDK_AAC=`pwd`/../fdk-aac-build-script-for-iOS/fdk-aac-ios
CONFIGURE_FLAGS="--enable-cross-compile --disable-debug --disable-programs \
--disable-doc --enable-pic"
if["$X264"]
then
CONFIGURE_FLAGS="$CONFIGURE_FLAGS --enable-gpl --enable-libx264"
fi
if["$FDK_AAC"]
then
CONFIGURE_FLAGS="$CONFIGURE_FLAGS --enable-libfdk-aac"
fi
# avresample
#CONFIGURE_FLAGS="$CONFIGURE_FLAGS --enable-avresample"
ARCHS="arm64 armv7 x86_64 i386"
COMPILE="y"
LIPO="y"
DEPLOYMENT_TARGET="6.0"
if["$*"]
then
if["$*"="lipo"]
then
# skip compile
COMPILE=
else
ARCHS="$*"
if[ $# -eq1]
then
# skip lipo
LIPO=
fi
fi
fi
if["$COMPILE"]
then
if[ !`which yasm`]
then
echo'Yasm not found'
if[ !`which brew`]
then
echo'Homebrew not found. Trying to install...'
ruby -e"$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"\
||exit1
fi
echo'Trying to install Yasm...'
brew install yasm ||exit1
fi
if[ !`which gas-preprocessor.pl`]
then
echo'gas-preprocessor.pl not found. Trying to install...'
(curl -L https://github.com/libav/gas-preprocessor/raw/master/gas-preprocessor.pl \
-o /usr/local/bin/gas-preprocessor.pl \
&& chmod +x /usr/local/bin/gas-preprocessor.pl) \
||exit1
fi
if[ ! -r $SOURCE ]
then
echo'FFmpeg source not found. Trying to download...'
curl http://www.ffmpeg.org/releases/$SOURCE.tar.bz2 | tar xj \
||exit1
fi
CWD=`pwd`
forARCHin$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"
CFLAGS="$CFLAGS -mios-simulator-version-min=$DEPLOYMENT_TARGET"
else
PLATFORM="iPhoneOS"
CFLAGS="$CFLAGS -mios-version-min=$DEPLOYMENT_TARGET -fembed-bitcode"
if["$ARCH"="arm64"]
then
EXPORT="GASPP_FIX_XCODE5=1"
fi
fi
XCRUN_SDK=`echo $PLATFORM | tr '[:upper:]' '[:lower:]'`
CC="xcrun -sdk $XCRUN_SDK clang"
CXXFLAGS="$CFLAGS"
LDFLAGS="$CFLAGS"
if["$X264"]
then
CFLAGS="$CFLAGS -I$X264/include"
LDFLAGS="$LDFLAGS -L$X264/lib"
fi
if["$FDK_AAC"]
then
CFLAGS="$CFLAGS -I$FDK_AAC/include"
LDFLAGS="$LDFLAGS -L$FDK_AAC/lib"
fi
TMPDIR=${TMPDIR/%\/} $CWD/$SOURCE/configure \
--target-os=darwin \
--arch=$ARCH \
--cc="$CC"\
$CONFIGURE_FLAGS \
--extra-cflags="$CFLAGS"\
--extra-ldflags="$LDFLAGS"\
--prefix="$THIN/$ARCH"\
||exit1
make -j3 install $EXPORT ||exit1
cd $CWD
done
fi
if["$LIPO"]
then
echo"building fat binaries..."
mkdir -p $FAT/lib
set - $ARCHS
CWD=`pwd`
cd $THIN/$1/lib
forLIBin*.a
do
cd $CWD
echo lipo -create`find $THIN -name $LIB`-output $FAT/lib/$LIB1>&2
lipo -create`find $THIN -name $LIB`-output $FAT/lib/$LIB ||exit1
done
cd $CWD
cp -rf $THIN/$1/include $FAT
fi
echo Done