mac 下移植 ffmpeg 支持x264 faac lame png 开启asm neon 加速

来源:互联网 发布:db ol联机网上数据库 编辑:程序博客网 时间:2024/06/05 19:09

mac 下移植 ffmpeg 支持x264 faac lame png 开启asm neon 加速 

1. 获取 ffmpeg 源码
http://ffmpeg.org/releases/ffmpeg-2.8.11.tar.bz2

2.再ffmpeg-2.8.11 平级目录下创建build-ffmpeg.sh
touch build-ffmpeg.sh

3.设置权限
sudo chmod 777 build-ffmpeg.sh

4. 编辑 build-ffmpeg.sh
#!/bin/sh# directoriesSOURCE="ffmpeg-2.8.11"FAT="FFmpeg-iOS"SCRATCH="scratch"# must be an absolute pathTHIN=`pwd`/"thin"# absolute path to x264 libraryX264=`pwd`/fat-x264#LIBPNG=`pwd`/libpngFDK_AAC=`pwd`/fdk-aac/fdk-aac-iosCONFIGURE_FLAGS="--enable-cross-compile --disable-debug --disable-programs \--disable-doc --enable-pic"if [ "$X264" ]thenCONFIGURE_FLAGS="$CONFIGURE_FLAGS --enable-gpl --enable-yasm --enable-asm --enable-libx264 --enable-decoder=h264 --enable-pthreads"fiif [ "$FDK_AAC" ]thenCONFIGURE_FLAGS="$CONFIGURE_FLAGS --enable-libmp3lame --enable-nonfree --enable-libfaac"fi# avresampleCONFIGURE_FLAGS="$CONFIGURE_FLAGS --enable-avresample"ARCHS="arm64 armv7 armv7s x86_64 i386"COMPILE="y"LIPO="y"DEPLOYMENT_TARGET="6.0"if [ "$*" ]thenif [ "$*" = "lipo" ]then# skip compileCOMPILE=elseARCHS="$*"if [ $# -eq 1 ]then# skip lipoLIPO=fififiif [ "$COMPILE" ]thenif [ ! `which yasm` ]thenecho 'Yasm not found'if [ ! `which brew` ]thenecho 'Homebrew not found. Trying to install...'ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" \|| exit 1fiecho 'Trying to install Yasm...'brew install yasm || exit 1fiif [ ! `which gas-preprocessor.pl` ]thenecho '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) \|| exit 1fiif [ ! -r $SOURCE ]thenecho 'FFmpeg source not found. Trying to download...'curl http://www.ffmpeg.org/releases/$SOURCE.tar.bz2 | tar xj \|| exit 1fiTEMP_CONFIGUR="$CONFIGURE_FLAGS"CWD=`pwd`for ARCH in $ARCHSdoecho "building $ARCH..."mkdir -p "$SCRATCH/$ARCH"cd "$SCRATCH/$ARCH"CONFIGURE_FLAGS="$TEMP_CONFIGUR"echo "$CONFIGURE_FLAGS"CFLAGS="-arch $ARCH"if [ "$ARCH" = "i386" -o "$ARCH" = "x86_64" ]thenPLATFORM="iPhoneSimulator"CFLAGS="$CFLAGS -mios-simulator-version-min=$DEPLOYMENT_TARGET"elsePLATFORM="iPhoneOS"CFLAGS="$CFLAGS -mios-version-min=$DEPLOYMENT_TARGET"if [ "$ARCH" = "armv7" ]thenCFLAGS="$CFLAGS -mfpu=neon -mfloat-abi=softfp "CONFIGURE_FLAGS="$CONFIGURE_FLAGS  --enable-neon --cpu=cortex-a8 --enable-optimizations --disable-ffmpeg --disable-ffplay --disable-ffserver --disable-doc"fiif [ "$ARCH" = "armv7s" ]thenCFLAGS="$CFLAGS -mfpu=neon -mfloat-abi=softfp "CONFIGURE_FLAGS="$CONFIGURE_FLAGS  --enable-neon --cpu=cortex-a8 --enable-optimizations --disable-ffmpeg --disable-ffplay --disable-ffserver --disable-doc"fiif [ "$ARCH" = "arm64" ]thenCFLAGS="$CFLAGS -mfpu=neon -mfloat-abi=softfp "CONFIGURE_FLAGS="$CONFIGURE_FLAGS  --enable-neon --enable-optimizations --disable-ffmpeg --disable-ffplay --disable-ffserver --disable-doc"EXPORT="GASPP_FIX_XCODE5=1"fifiXCRUN_SDK=`echo $PLATFORM | tr '[:upper:]' '[:lower:]'`CC="xcrun -sdk $XCRUN_SDK clang"CXXFLAGS="$CFLAGS"LDFLAGS="$CFLAGS"if [ "$X264" ]thenCFLAGS="$CFLAGS -I$X264/include"LDFLAGS="$LDFLAGS -L$X264/lib"fiif [ "$FDK_AAC" ]thenCFLAGS="$CFLAGS -I$FDK_AAC/include"LDFLAGS="$LDFLAGS -L$FDK_AAC/lib"fiif [ "$LIBPNG" ]thenCFLAGS="$CFLAGS -I$LIBPNG/include"LDFLAGS="$LDFLAGS -L$LIBPNG/lib"fiTMPDIR=${TMPDIR/%\/} $CWD/$SOURCE/configure \--target-os=darwin \--arch=$ARCH \--cc="$CC" \$CONFIGURE_FLAGS \--extra-cflags="$CFLAGS" \--extra-cxxflags="$CXXFLAGS" \--extra-ldflags="$LDFLAGS" \--prefix="$THIN/$ARCH" \|| exit 1make cleanmake -j3 install $EXPORT || exit 1cd $CWDdonefiif [ "$LIPO" ]thenecho "building fat binaries..."mkdir -p $FAT/libset - $ARCHSCWD=`pwd`cd $THIN/$1/libfor LIB in *.adocd $CWDecho lipo -create `find $THIN -name $LIB` -output $FAT/lib/$LIB 1>&2lipo -create `find $THIN -name $LIB` -output $FAT/lib/$LIB || exit 1donecd $CWDcp -rf $THIN/$1/include $FATfiecho Done

5. 执行之前请把之前交叉编译好的库放到平级目下,否则会报找不到库的错误
sudo ./build-ffmpeg.sh

6. 最终会在FFmpeg-iOS 文件夹下生成对应的打包的库
github地址:https://github.com/a553110519/ffmpeg-ios.git
阅读全文
0 0
原创粉丝点击