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

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

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

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

  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

Xcode5编译ffmpeg的更多相关文章

  1. XCode5 编译ffmpeg流程

    今天想在Mac10.9 XCode5的环境下把ffmpeg编译出来,本来以为很好搞定,结果版本一升级,以前的命令行不通了,出各种错误.折腾了三四个小时,最后终于成功了. 编译流程: 1.ffmpeg官 ...

  2. Xcode5 编译ffmpeg,arm64版本;H264

    编译选项:./configure  —-cc=/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchai ...

  3. Xcode编译ffmpeg(2)

    iOS: FFmpeg编译和使用问题总结 折磨了我近一周多时间的FFmpeg库编译问题终于解决了,必须得把这一段时间来遇到过的坑全写出来.如果急着解决问题,编译最新版本的FFmpeg库请直接看第二部分 ...

  4. iOS编译FFmpeg、kxmovie实现视频播放 (转载)

    由于FFmpeg开源框架的功能非常强大,可以播放的视频种类很多,同时添加第三方库kxmovie,实现视频播放,真的是爽爆了,因此今天来说一下关于FFmpeg在iOS手机上的一些配置过程,配置工具,还有 ...

  5. 编译FFmpeg成一个SO库<转>

    转帖地址:http://www.ihubin.com/blog/android-ffmpeg-demo-3/ ============================================= ...

  6. Linux下NDK编译FFMPEG包含neon参数

    FFMPEG编译成Android库已经有很多案例了,编译优化neon的也很多,以下是我通过实践成功的案例,这里主要讲编译的配置文件,其他设置可结合Linux下使用NDK编译FFMPEG(libstag ...

  7. [原]如何用Android NDK编译FFmpeg

    我们知道在Ubuntu下直接编译FFmpeg是很简单的,主要是先执行./configure,接着执行make命令来编译,完了紧接着执行make install执行安装.那么如何使用Android的ND ...

  8. 在Windows下利用MinGW编译FFmpeg

    目录 [隐藏]  1 环境与软件 2 第一步:安装MinGW 3 第二步:配置编译环境 4 第三步:配置SDL 5 第四步:编译 5.1 编译faac 5.2 编译fdk-aac 5.3 编译x264 ...

  9. 开源项目:windows下使用MinGW+msys编译ffmpeg

    本文参考了网络上的不少文章,但由于版本环境的问题参考文章并不能直接指导编译,本文吸收多方经验,并在自己多次编译实验的基础上写成,欢迎转载,请注名出处.    FFmpeg是在Linux平台下开发的,但 ...

随机推荐

  1. 进程间通信之-共享内存Shared Memory--linux内核剖析(十一)

    共享内存 共享内存是进程间通信中最简单的方式之中的一个. 共享内存是系统出于多个进程之间通讯的考虑,而预留的的一块内存区. 共享内存同意两个或很多其他进程訪问同一块内存,就如同 malloc() 函数 ...

  2. java 开发webservice

    这几天用java开发一个webservice,搞死了.java果然很难侍候! 传说java搞webservice,有好几种途径(为什么不是一种?要搞这么多种,让人一听,头都大了.当然啦,生物多样性总是 ...

  3. vue 基础知识 随笔

    window.localStorage.gettItem("someItem"||[])//如果localStorage中的someItem不存在就返回一个空数组 window.l ...

  4. Python 之reduce()函数

    reduce()函数: reduce()函数也是Python内置的一个高阶函数.reduce()函数接收的参数和 map()类似,一个函数 f,一个list,但行为和 map()不同,reduce() ...

  5. E20171123-sl

    conform  vi. 符合; 遵照; 适应环境;               vi. 符合; 遵照; 适应环境;                 adj. 一致的; 顺从的; investigat ...

  6. bzoj 1673: [Usaco2005 Dec]Scales 天平【dfs】

    真是神奇 根据斐波那契数列,这个a[i]<=c的最大的i<=45,所以直接搜索即可 #include<iostream> #include<cstdio> usin ...

  7. vs2017 + miniUI 后端框架使用

    vs2017 +  miniUI  后端框架使用 上miniUI官网直接下载框架.http://www.miniui.com/ 此框架使用说明很清楚. 2.1.vs2017创建安装miniUI后端框架 ...

  8. java entity

    对java实体类的众多理解: A .就是属性类,通常定义在model层里面 B. 一般的实体类对应一个数据表,其中的属性对应数据表中的字段.好处:1.对对象实体的封装,体现OO思想.2.属性可以对字段 ...

  9. spring 异常处理

    1. 实现接口 HandlerExceptionResolver 捕获异常 2.@ExceptionHandler 在方法添加注解,捕获本地controller异常 3.@ControllerAdvi ...

  10. 清理TIME_WAIT

    cat >> /etc/sysctl.conf << EOFnet.ipv4.tcp_tw_reuse=1net.ipv4.tcp_tw_recycle=1net.ipv4.t ...