mac 下移植 ffmpeg 支持x264 faac lame png 开启asm neon 加速
2017-05-19 19:45
706 查看
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 # directories SOURCE="ffmpeg-2.8.11" FAT="FFmpeg-iOS" SCRATCH="scratch" # must be an absolute path THIN=`pwd`/"thin" # absolute path to x264 library X264=`pwd`/fat-x264 #LIBPNG=`pwd`/libpng FDK_AAC=`pwd`/fdk-aac/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-yasm --enable-asm --enable-libx264 --enable-decoder=h264 --enable-pthreads" fi if [ "$FDK_AAC" ] then CONFIGURE_FLAGS="$CONFIGURE_FLAGS --enable-libmp3lame --enable-nonfree --enable-libfaac" fi # avresample CONFIGURE_FLAGS="$CONFIGURE_FLAGS --enable-avresample" ARCHS="arm64 armv7 armv7s x86_64 i386" COMPILE="y" LIPO="y" DEPLOYMENT_TARGET="6.0" if [ "$*" ] then if [ "$*" = "lipo" ] then # skip compile COMPILE= else ARCHS="$*" if [ $# -eq 1 ] 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)" \ || exit 1 fi echo 'Trying to install Yasm...' brew install yasm || exit 1 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) \ || exit 1 fi if [ ! -r $SOURCE ] then echo 'FFmpeg source not found. Trying to download...' curl http://www.ffmpeg.org/releases/$SOURCE.tar.bz2 | tar xj \ || exit 1 fi TEMP_CONFIGUR="$CONFIGURE_FLAGS" CWD=`pwd` for ARCH in $ARCHS do echo "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" ] then PLATFORM="iPhoneSimulator" CFLAGS="$CFLAGS -mios-simulator-version-min=$DEPLOYMENT_TARGET" else PLATFORM="iPhoneOS" CFLAGS="$CFLAGS -mios-version-min=$DEPLOYMENT_TARGET" if [ "$ARCH" = "armv7" ] then CFLAGS="$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" fi if [ "$ARCH" = "armv7s" ] then CFLAGS="$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" fi if [ "$ARCH" = "arm64" ] then CFLAGS="$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" 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 if [ "$LIBPNG" ] then CFLAGS="$CFLAGS -I$LIBPNG/include" LDFLAGS="$LDFLAGS -L$LIBPNG/lib" fi TMPDIR=${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 1 make clean make -j3 install $EXPORT || exit 1 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 echo lipo -create `find $THIN -name $LIB` -output $FAT/lib/$LIB 1>&2 lipo -create `find $THIN -name $LIB` -output $FAT/lib/$LIB || exit 1 done cd $CWD cp -rf $THIN/$1/include $FAT fi echo Done
5. 执行之前请把之前交叉编译好的库放到平级目下,否则会报找不到库的错误
sudo ./build-ffmpeg.sh
6. 最终会在FFmpeg-iOS 文件夹下生成对应的打包的库
github地址:https://github.com/a553110519/ffmpeg-ios.git
相关文章推荐
- xcode 下 ffmpeg soundtouch faac x264 libyuv lame 一次打包armv7 armv7s arm64
- mac 下移植 x264 使用 neon 多线程加速
- 编译安装ffmpeg 要支持xvid、x264、mp3、ogg、amr、faac
- 编译安装ffmpeg 要支持xvid、x264、mp3、ogg、amr、faac
- ffmpeg(From SVN)移植过程(含SDL、lame、x264等lib)
- 编译支持x264 编码的ffmpeg并成功移植到docker
- 编译安装FFmpeg 要支持xvid、x264、mp3、ogg、amr、faac
- 安装FFmpeg x264支持到时候遇到了 “libx264 not found”
- Android平台移植FFmpeg和x264
- FFmpeg-3.3.1移植到Android平台(Mac编译)
- PHP支持ffmpeg,便用ffmpeg命令处理视频,开启exec权限
- ubuntu和arm平台下的ffmpeg和x264相关库的移植
- FinalShell SSH工具,服务器管理,远程桌面加速软件,支持Windows,Mac OS X,Linux,版本2.8.1
- ffmpeg支持x264的android平台编译
- Linux下编译ffmpeg和x264支持的opencv
- Mac OS X下使用Homebrew安装PNG支持——重新编译PHP
- 如何在Mac上开启NTFS读取支持
- 树莓派x264和ffmpeg编译(用于支持GPU硬件编解码)
- linux 编译ffmpeg 支持x264, x265
- 交叉编译移植 FFMPEG X264 XVID 到 hi3531