Xcode5编译ffmpeg

  1. 命令行安装FFmpeg:git clone git://source.ffmpeg.org/ffmpeg.git ffmpeg(或:到https://github.com/gabriel/ffmpeg-iphone-build下载ffmpeg-iphone-build)

  2. 安装命令行工具(Command Line Tools)

    打开终端,输入命令:xcode-select --install

    osx-10.9-clt-1

     

    选择“安装”,然后同意安装协议。

    osx-10.9-clt-2

     

    osx-10.9-clt-3

     

  3. 下载gas-preprocessor:https://github.com/mansr/gas-preprocessor, 先将gas-preprocessor.pl拷贝到/usr/sbin/目录中。

    然后修改gas-preprocessor.pl文件的权限。注:需要有读,写和执行的权限。具体操作为,首先在命令行下进入/usr/bin目录,然后执行chmod命令,如下图所示:

    13224613-88afdd0778fa46bda8c5a6549a0febf

     

  4. 运行build-ffmpeg.sh文件:

    1、cd  /build-ffmpeg.sh 脚本的所在目录下

    2、sh build-ffmpeg.sh

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    #!/bin/bash
    ###########################################################################
    #  Choose your ffmpeg version and your currently-installed iOS SDK version:
    #
    VERSION= "2.0.2"
    SDKVERSION= "7.0"
    #
    #
    ###########################################################################
    #
    # Don't change anything under  this  line!
    #
    ###########################################################################
    # No need to change  this  since xcode build will only compile  in  the
    # necessary bits from the libraries we create
    ARCHS= "armv7 armv7s i386"
    DEVELOPER=`xcode-select -print-path`
    cd  "`dirname \"$0\"`"
    REPOROOT=$(pwd)
    # Where we'll end up storing things  in  the end
    OUTPUTDIR= "${REPOROOT}/dependencies"
    mkdir -p ${OUTPUTDIR}/ include
    mkdir -p ${OUTPUTDIR}/lib
    mkdir -p ${OUTPUTDIR}/bin
    BUILDDIR= "${REPOROOT}/build"
    mkdir -p $BUILDDIR
    # where we will keep our sources and build from.
    SRCDIR= "${BUILDDIR}/src"
    mkdir -p $SRCDIR
    # where we will store intermediary builds
    INTERDIR= "${BUILDDIR}/built"
    mkdir -p $INTERDIR
    ########################################
    cd $SRCDIR
    # Exit the script  if  an error happens
    set  -e
    if  [ ! -e  "${SRCDIR}/ffmpeg-${VERSION}.tar.bz2"  ]; then
         echo  "Downloading ffmpeg-${VERSION}.tar.bz2"
         curl -LO http: //ffmpeg.org/releases/ffmpeg-${VERSION}.tar.bz2
    else
         echo  "Using ffmpeg-${VERSION}.tar.bz2"
    fi
    tar jxf ffmpeg-${VERSION}.tar.bz2 -C $SRCDIR
    cd  "${SRCDIR}/ffmpeg-${VERSION}"
    set  +e # don 't bail out of bash script if ccache doesn' t exist
    CCACHE=`which ccache`
    if  [ $? ==  "0"  ]; then
         echo  "Building with ccache: $CCACHE"
         CCACHE= "${CCACHE} "
    else
         echo  "Building without ccache"
         CCACHE= ""
    fi
    set  -e # back to regular  "bail out on error"  mode
    for  ARCH  in  ${ARCHS}
    do
         if  "${ARCH}"  ==  "i386"  ];
         then
             PLATFORM= "iPhoneSimulator"
             EXTRA_CONFIG= "--arch=i386 --disable-asm --enable-cross-compile --target-os=darwin --cpu=i386"
             EXTRA_CFLAGS= "-arch i386"
             EXTRA_LDFLAGS= "-I${DEVELOPER}/Platforms/${PLATFORM}.platform/Developer/SDKs/${PLATFORM}${SDKVERSION}.sdk/usr/lib -mfpu=neon"
         else
             PLATFORM= "iPhoneOS"
             EXTRA_CONFIG= "--arch=arm --target-os=darwin --enable-cross-compile --cpu=cortex-a9 --disable-armv5te"
             EXTRA_CFLAGS= "-w -arch ${ARCH} -mfpu=neon"
             EXTRA_LDFLAGS= "-mfpu=neon"
         fi
         mkdir -p  "${INTERDIR}/${ARCH}"
         ./configure --prefix= "${INTERDIR}/${ARCH}"  --disable-ffmpeg --disable-ffplay --disable-ffprobe --disable-ffserver --disable-iconv --disable-bzlib --enable-avresample --sysroot= "${DEVELOPER}/Platforms/${PLATFORM}.platform/Developer/SDKs/${PLATFORM}${SDKVERSION}.sdk"  --cc= "${DEVELOPER}/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang"  -- as = '/usr/local/bin/gas-preprocessor.pl'  --extra-cflags= "${EXTRA_CFLAGS} -miphoneos-version-min=${SDKVERSION} -I${OUTPUTDIR}/include"  --extra-ldflags= "-arch ${ARCH} ${EXTRA_LDFLAGS} -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/${PLATFORM}.platform/Developer/SDKs/${PLATFORM}${SDKVERSION}.sdk -miphoneos-version-min=${SDKVERSION} -L${OUTPUTDIR}/lib"  ${EXTRA_CONFIG} --enable-pic --extra-cxxflags= "$CPPFLAGS -I${OUTPUTDIR}/include -isysroot ${DEVELOPER}/Platforms/${PLATFORM}.platform/Developer/SDKs/${PLATFORM}${SDKVERSION}.sdk"
         make && make install && make clean
                                                                                                                                
    done
    mkdir -p  "${INTERDIR}/universal/lib"
    cd  "${INTERDIR}/armv7/lib"
    for  file  in  *.a
    do
    cd ${INTERDIR}
    xcrun -sdk iphoneos lipo -output universal/lib/$file  -create -arch armv7 armv7/lib/$file -arch armv7s armv7s/lib/$file -arch i386 i386/lib/$file
    echo  "Universal $file created."
    done
    cp -r ${INTERDIR}/armv7/ include  ${INTERDIR}/universal/
    echo  "Done."

     

  5. 把/build/built/universal目录下的 lib 和 include 文件导入工程,并在header search path 配置 include文件 路径。

 

本文出自 “追逐风飞的花” 博客,请务必保留此出处http://metoo.blog.51cto.com/7809119/1382158

转载于:https://www.cnblogs.com/yulang314/p/3710272.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值