由于要寫iOS播放器钦奋,需要用到effmpeg、x264庫
1疙赠、編譯effmpeg
具體步驟如下:
- 下載腳本:https://github.com/kewlbear/FFmpeg-iOS-build-script
- 解壓付材,找到文件 build-ffmpeg.sh
- 運行 build-ffmpeg.sh
如果有問題請查看參考資料:
http://www.cocoachina.com/ios/20150514/11827.html
2、編譯x264
1.首先到http://www.videolan.org/developers/x264.html 下載最新的libx264源碼包圃阳,解壓之后是一個含snapshot-xxxx的一個文件夾厌衔,把它拷貝到隨便一個文件夾下,重命名為x264;
2.到https://github.com/kewlbear/x264-ios 下載x264的一鍵編譯腳本文件捍岳,把它放到跟x264文件夾同級的地方富寿;
3.運行腳本./build-x264.sh;
參考資料:
http://blog.sina.com.cn/s/blog_47522f7f0102vcbj.html
3锣夹、編譯aac
1.代碼下載
在mac下面執(zhí)行:wget http://downloads.sourceforge.net/project/faac/faac-src/faac-1.28/faac-1.28.tar.gz
也可以用網頁打開下載页徐,不過我用網頁打開下載老是失敗,后來就命令下載一次性成功银萍。
2.代碼編譯
下載以后解壓文件变勇,解壓以后的文件夾名修改為faac
faac腳本如下:
#!/bin/sh
CONFIGURE_FLAGS="--enable-static --with-pic"
ARCHS="arm64 armv7s armv7 x86_64 i386"
# directories
SOURCE="faac"
FAT="fat-faac"
SCRATCH="scratch-faac"
# must be an absolute path
THIN=`pwd`/"thin-faac"
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"
if [ "$ARCH" = "i386" -o "$ARCH" = "x86_64" ]
then
PLATFORM="iPhoneSimulator"
CPU=
if [ "$ARCH" = "x86_64" ]
then
SIMULATOR="-mios-simulator-version-min=7.0"
HOST=
else
SIMULATOR="-mios-simulator-version-min=5.0"
HOST="--host=i386-apple-darwin"
fi
else
PLATFORM="iPhoneOS"
if [ $ARCH = "armv7s" ]
then
CPU="--cpu=swift"
else
CPU=
fi
SIMULATOR=
HOST="--host=arm-apple-darwin"
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"
CFLAGS="-arch $ARCH $SIMULATOR"
CXXFLAGS="$CFLAGS"
LDFLAGS="$CFLAGS"
CC=$CC CFLAGS=$CXXFLAGS LDFLAGS=$LDFLAGS CPPFLAGS=$CXXFLAGS CXX=$CC CXXFLAGS=$CXXFLAGS $CWD/$SOURCE/configure \
$CONFIGURE_FLAGS \
$HOST \
--prefix="$THIN/$ARCH" \
--disable-shared \
--without-mp4v2
make clean && make && make install-strip
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
參考資料:
http://blog.csdn.net/cjj198561/article/details/38382889