1. 首先去FFmpeg官網(wǎng)下載FFmpeg庫: 當(dāng)前我下載的版本是:ffmpeg-3.4
https://www.ffmpeg.org/
2. 下載后解壓文件夾為: 解壓后的文件夾如圖: ffmpeg-3.4
2.1. 將?ffmpeg-3.4 文件夾放到某個(gè)文件夾里面: 例如我自己放在?clark-ffmpeg-iOS ?文件夾下面:(文件夾名字不能有空格)
2.2. 將?gas-preprocessor.pl 文件也復(fù)制到?clark-ffmpeg-iOS ?文件夾下面
2.3. 重點(diǎn)就是?ffmpeg-build.sh 編譯ffmpeg 庫的腳本了稿存, 下面主要講解這個(gè)文件內(nèi)容
3. 打開?ffmpeg-build.sh 腳本文件如圖:
4. 直接復(fù)制如下腳本用:
#!/bin/bash
source="ffmpeg-3.4"
cache="cache"
staticdir=`pwd`/"clark-ffmpeg-iOS"
configure_flags="--enable-cross-compile --disable-debug --disable-programs --disable-doc --enable-pic"
archs="arm64 armv7 x86_64 i386"
targetversion="7.0"
if [ "$*" ]
then
archs="$*"
fi
if [ ! `which yasm`? ]
then
if [ ! `which brew` ]
then
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" || exit 1
fi
brew install yasm || exit 1
fi
currentdir=`pwd`
for arch in $archs
do
mkdir -p "$cache/$arch"
cd "$cache/$arch"
archflags="-arch $arch"
if [ "$arch" = "i386" -o "$arch" = "x86_64" ]
then
platform="iPhoneSimulator"
archflags="$archflags -mios-simulator-version-min=$targetversion"
else
platform="iPhoneOS"
archflags="$archflags -mios-version-min=$targetversion -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"
if [ "$arch" = "arm64" ]
then
AS="gas-preprocessor.pl -arch aarch64 -- $CC"
else
AS="$CC"
fi
TMPDIR=${TMPDIR/%\/} $currentdir/$source/configure \
--target-os=darwin \
--arch=$arch \
--cc="$CC" \
--as="$AS" \
$configure_flags \
--extra-cflags="$archflags" \
--extra-ldflags="$archflags" \
--prefix="$staticdir/$arch" \
|| exit 1
make -j3 install $EXPORT || exit 1
cd $currentdir
done
5. 運(yùn)行腳本童番,指定 arm64 架構(gòu),也可以生成其它的架構(gòu),用lipo 命令合并也可以:
6. 等一會(huì)....就開始編譯庫了, 生成完如圖:
7. 搞定,拖include/lib 到工程中配置一下就可以使用了。