最近比较闲,苦于ios设备上没有直接播放torrent 文件的软件,开始折腾了.找了不少资料有了思路.但是其中用到了ffmpeg 这个东西.

  ffmpeg 是通用的一个视频解决框架,用C语言编写,通用性很强.

  1. 编译ffmpeg.
    1. 下载源码后可以自己手动编译 ,反正是通过各种命令 配置configure
    2. 通过一个很牛逼的脚本:git@github.com:kewlbear/FFmpeg-iOS-build-script.git     下载之后,检查ffmpeg的版本号,替换成最新的 然后运行脚本就行了
      #!/bin/sh
      
      # directories
      SOURCE="ffmpeg-2.5"
      FAT="FFmpeg-iOS" SCRATCH="scratch"
      # must be an absolute path
      THIN=`pwd`/"thin" # absolute path to x264 library
      #X264=`pwd`/fat-x264 #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-libx264"
      fi if [ "$FDK_AAC" ]
      then
      CONFIGURE_FLAGS="$CONFIGURE_FLAGS --enable-libfdk-aac"
      fi # avresample
      #CONFIGURE_FLAGS="$CONFIGURE_FLAGS --enable-avresample" ARCHS="arm64 armv7s armv7 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.github.com/Homebrew/homebrew/go/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 CWD=`pwd`
      for ARCH in $ARCHS
      do
      echo "building $ARCH..."
      mkdir -p "$SCRATCH/$ARCH"
      cd "$SCRATCH/$ARCH" 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" = "arm64" ]
      then
      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 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 -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
  2. 导入项目,有静态包经验的就就不用看了,这个对于我这个半路出家的和尚还是处理了老半天才解决.
    .a文件直接导入 .h文件要导入文件夹结构   配置header search 环境变量  使用的时候导入文件 结构:#import "文件夹/文件.h"
  3. 编译.
    1. 首次编译.

      Undefined symbols for architecture armv7:
      "_deflateInit2_", referenced from:
      _encode_frame in libavcodec.a(pngenc.o)
      "_crc32", referenced from:
      _encode_frame in libavcodec.a(pngenc.o)
      "_deflateReset", referenced from:
      _encode_frame in libavcodec.a(lclenc.o)
      _encode_frame in libavcodec.a(zmbvenc.o)
      "_compress", referenced from:
      _encode_strip in libavcodec.a(tiffenc.o)
      "_deflateBound", referenced from:
      _flashsv_decode_frame in libavcodec.a(flashsv.o)
      _encode_frame in libavcodec.a(pngenc.o)
      _encode_frame in libavcodec.a(lclenc.o)
      "_inflateSync", referenced from:
      _flashsv_decode_frame in libavcodec.a(flashsv.o)
      "_inflateReset", referenced from:
      _flashsv_decode_frame in libavcodec.a(flashsv.o)
      _zlib_decomp in libavcodec.a(lcldec.o)
      _decode_frame in libavcodec.a(tscc.o)
      _zerocodec_decode_frame in libavcodec.a(zerocodec.o)
      _decode_frame in libavcodec.a(zmbv.o)
      "_iconv_open", referenced from:
      _avcodec_open2 in libavcodec.a(utils.o)
      _avcodec_decode_subtitle2 in libavcodec.a(utils.o)
      "_BZ2_bzDecompress", referenced from:
      _matroska_decode_buffer in libavformat.a(matroskadec.o)
      "_inflate", referenced from:
      _http_read_stream in libavformat.a(http.o)
      _matroska_decode_buffer in libavformat.a(matroskadec.o)
      _rtmp_open in libavformat.a(rtmpproto.o)
      _zlib_refill in libavformat.a(swfdec.o)
      _decode_frame_common in libavcodec.a(pngdec.o)
      _decode_text_chunk in libavcodec.a(pngdec.o)
      _flashsv_decode_frame in libavcodec.a(flashsv.o)
      ...
      "_inflateInit_", referenced from:
      _matroska_decode_buffer in libavformat.a(matroskadec.o)
      _rtmp_open in libavformat.a(rtmpproto.o)
      _swf_read_header in libavformat.a(swfdec.o)
      _decode_frame_apng in libavcodec.a(pngdec.o)
      _decode_frame_png in libavcodec.a(pngdec.o)
      _decode_text_chunk in libavcodec.a(pngdec.o)
      _flashsv_decode_init in libavcodec.a(flashsv.o)
      ...
      "_iconv", referenced from:
      _avcodec_decode_subtitle2 in libavcodec.a(utils.o)
      "_BZ2_bzDecompressEnd", referenced from:
      _matroska_decode_buffer in libavformat.a(matroskadec.o)
      "_inflateInit2_", referenced from:
      _http_read_header in libavformat.a(http.o)
      "_deflateEnd", referenced from:
      _flashsv_decode_frame in libavcodec.a(flashsv.o)
      _flashsv2_encode_frame in libavcodec.a(flashsv2enc.o)
      _flashsv_encode_init in libavcodec.a(flashsvenc.o)
      _flashsv_encode_end in libavcodec.a(flashsvenc.o)
      _encode_frame in libavcodec.a(pngenc.o)
      _encode_end in libavcodec.a(lclenc.o)
      _encode_init in libavcodec.a(zmbvenc.o)
      ...
      "_BZ2_bzDecompressInit", referenced from:
      _matroska_decode_buffer in libavformat.a(matroskadec.o)
      "_deflateInit_", referenced from:
      _flashsv_decode_frame in libavcodec.a(flashsv.o)
      _flashsv2_encode_frame in libavcodec.a(flashsv2enc.o)
      _encode_init in libavcodec.a(lclenc.o)
      _encode_init in libavcodec.a(zmbvenc.o)
      "_zlibCompileFlags", referenced from:
      _http_read_header in libavformat.a(http.o)
      "_compress2", referenced from:
      _flashsv2_encode_frame in libavcodec.a(flashsv2enc.o)
      _flashsv_encode_frame in libavcodec.a(flashsvenc.o)
      "_deflate", referenced from:
      _flashsv_decode_frame in libavcodec.a(flashsv.o)
      _flashsv2_encode_frame in libavcodec.a(flashsv2enc.o)
      _encode_frame in libavcodec.a(pngenc.o)
      _encode_frame in libavcodec.a(lclenc.o)
      _encode_frame in libavcodec.a(zmbvenc.o)
      "_inflateEnd", referenced from:
      _http_close in libavformat.a(http.o)
      _http_read_header in libavformat.a(http.o)
      _matroska_decode_buffer in libavformat.a(matroskadec.o)
      _rtmp_open in libavformat.a(rtmpproto.o)
      _swf_read_close in libavformat.a(swfdec.o)
      _decode_frame_apng in libavcodec.a(pngdec.o)
      _decode_frame_png in libavcodec.a(pngdec.o)
      ...
      "_uncompress", referenced from:
      _id3v2_read_internal in libavformat.a(id3v2.o)
      _mov_read_cmov in libavformat.a(mov.o)
      _swf_read_packet in libavformat.a(swfdec.o)
      _decode_frame in libavcodec.a(cscd.o)
      _decode_frame in libavcodec.a(dxa.o)
      _decode_block in libavcodec.a(exr.o)
      _g2m_decode_frame in libavcodec.a(g2meet.o)
      ...
      "_iconv_close", referenced from:
      _avcodec_open2 in libavcodec.a(utils.o)
      _avcodec_decode_subtitle2 in libavcodec.a(utils.o)
      ld: symbol(s) not found for architecture armv7
      clang: error: linker command failed with exit code (use -v to see invocation)

      导入 libz.1.2.5.dylib ,再次编译

      Undefined symbols for architecture armv7:
      "_BZ2_bzDecompressInit", referenced from:
      _matroska_decode_buffer in libavformat.a(matroskadec.o)
      "_iconv", referenced from:
      _avcodec_decode_subtitle2 in libavcodec.a(utils.o)
      "_BZ2_bzDecompress", referenced from:
      _matroska_decode_buffer in libavformat.a(matroskadec.o)
      "_BZ2_bzDecompressEnd", referenced from:
      _matroska_decode_buffer in libavformat.a(matroskadec.o)
      "_iconv_open", referenced from:
      _avcodec_open2 in libavcodec.a(utils.o)
      _avcodec_decode_subtitle2 in libavcodec.a(utils.o)
      "_iconv_close", referenced from:
      _avcodec_open2 in libavcodec.a(utils.o)
      _avcodec_decode_subtitle2 in libavcodec.a(utils.o)
      ld: symbol(s) not found for architecture armv7
      clang: error: linker command failed with exit code (use -v to see invocation)

      导入 libbz2.1.0.dylib ,再次编译

      Undefined symbols for architecture armv7:
      "_iconv", referenced from:
      _avcodec_decode_subtitle2 in libavcodec.a(utils.o)
      "_iconv_open", referenced from:
      _avcodec_open2 in libavcodec.a(utils.o)
      _avcodec_decode_subtitle2 in libavcodec.a(utils.o)
      "_iconv_close", referenced from:
      _avcodec_open2 in libavcodec.a(utils.o)
      _avcodec_decode_subtitle2 in libavcodec.a(utils.o)
      ld: symbol(s) not found for architecture armv7
      clang: error: linker command failed with exit code (use -v to see invocation)

      导入  libiconv.2.4.0.dylib  编译通过   3.0 后不通过

      Undefined symbols for architecture x86_64:
      "_CMBlockBufferCreateWithMemoryBlock", referenced from:
      _videotoolbox_common_end_frame in libavcodec.a(videotoolbox.o)
      "_CMSampleBufferCreate", referenced from:
      _videotoolbox_common_end_frame in libavcodec.a(videotoolbox.o)
      "_CMVideoFormatDescriptionCreate", referenced from:
      _av_videotoolbox_default_init2 in libavcodec.a(videotoolbox.o)
      "_VTDecompressionSessionCreate", referenced from:
      _av_videotoolbox_default_init2 in libavcodec.a(videotoolbox.o)
      "_VTDecompressionSessionDecodeFrame", referenced from:
      _videotoolbox_common_end_frame in libavcodec.a(videotoolbox.o)
      "_VTDecompressionSessionInvalidate", referenced from:
      _av_videotoolbox_default_free in libavcodec.a(videotoolbox.o)
      "_VTDecompressionSessionWaitForAsynchronousFrames", referenced from:
      _videotoolbox_common_end_frame in libavcodec.a(videotoolbox.o)
      "_kCMFormatDescriptionExtension_SampleDescriptionExtensionAtoms", referenced from:
      _av_videotoolbox_default_init2 in libavcodec.a(videotoolbox.o)
      ld: symbol(s) not found for architecture x86_64
      clang: error: linker command failed with exit code (use -v to see invocation)

      导入 CoreMedia.framework  编译

      Undefined symbols for architecture x86_64:
      "_VTDecompressionSessionCreate", referenced from:
      _av_videotoolbox_default_init2 in libavcodec.a(videotoolbox.o)
      "_VTDecompressionSessionDecodeFrame", referenced from:
      _videotoolbox_common_end_frame in libavcodec.a(videotoolbox.o)
      "_VTDecompressionSessionInvalidate", referenced from:
      _av_videotoolbox_default_free in libavcodec.a(videotoolbox.o)
      "_VTDecompressionSessionWaitForAsynchronousFrames", referenced from:
      _videotoolbox_common_end_frame in libavcodec.a(videotoolbox.o)
      ld: symbol(s) not found for architecture x86_64

      导入 VideoToolbox.framework  编译通过

  到此准备结束

ffmpeg xcode 中的使用的更多相关文章

  1. iOS开发时,在Xcode中添加多个Targets进行版本控制

    在iOS开发中,很可能有以下场景:需要开发多个版本,或因需区分收费版,免费版,或因为网络环境需要区分测试版,发布版,或因渠道不同需要区分企业版,AppStore版等等.解决办法无非就是CheckOut ...

  2. 在Xcode中使用Git进行源码版本控制

    http://www.cocoachina.com/ios/20140524/8536.html 资讯 论坛 代码 工具 招聘 CVP 外快 博客new 登录| 注册   iOS开发 Swift Ap ...

  3. 解决cocos2dx在Xcode中运行时报:convert: iCCP: known incorrect sRGB profile 的问题

    解决cocos2dx在Xcode中运行时报:convert: iCCP: known incorrect sRGB profile 的问题 本文的实践来源是参照了两个帖子完成的: http://dis ...

  4. Xcode中iPhone iPad模拟器调整大小的方法

    Xcode中调试iPad程序默认的iPad模拟器非常小,如何方法iPad模拟器的显示尺寸呢? 选中iOS模拟器,在“Window -> 缩放比例”中就可以调整了. 快捷键: Command + ...

  5. [翻译]使用Swift在Xcode中创建自定义控件

    使用Swift在Xcode中创建自定义控件 原文 IBDesignable and IBInspectable With IBDesignable and IBInspectable, develop ...

  6. 使用 Git 来管理 Xcode 中的代码片段

    使用 Git 来管理 Xcode 中的代码片段 代码片段介绍 xcode4 引入了一个新 feature: code snippets,在整个界面的右下角,可以通过快捷键:cmd + ctrl + o ...

  7. XCODE中的蓝色文件夹与黄色文件夹

    XCODE中的蓝色文件夹与黄色文件夹 黄色文件夹比较常见 - group , 在XCODE中以文件夹的形式存在,有层次感,但是实际文件在工程下是散乱的,没有层级结构.是XCODE中虚拟目录. 蓝色文件 ...

  8. 网络粘贴---Xcode中可用到的快捷键

    快捷键: 1.StoryBoard技巧 当你想直接在view中选择自己想要的元素时,但是又碍于一个view上叠加的元素太多很难直接选中,那么在这时,你同时按住键盘上的shift和 control键,然 ...

  9. Xcode 中 Git 的配置与使用

    Xcode 中 Git 的配置与使用主要围绕下面几个问题展开阐述: 问题1,如何在Xcode中创建本地代码库,并添加和提交代码到本地代码库? 问题2,如何在Xcode中提交推送给远程服务器代码库? 问 ...

随机推荐

  1. CDOJ_149 解救小Q

    原题网址:http://acm.uestc.edu.cn/#/problem/show/149 小Q被邪恶的大魔王困在了迷宫里,love8909决定去解救她. 迷宫里面有一些陷阱,一旦走到陷阱里,就会 ...

  2. LINUX___的常用几个快捷键

    linux下:ctrl-c 发送 SIGINT 信号给前台进程组中的所有进程.常用于终止正在运行的程序.ctrl-z 发送 SIGTSTP 信号给前台进程组中的所有进程,常用于挂起一个进程.ctrl- ...

  3. linux下添加定时任务。

    这周要做一个定时增量更新Elasticsearch索引的功能,以前没有做过定时更新,所以请教了下同事,使用crontab添加linux下的定时任务. 一.linux下定时执行任务的方法 在linux中 ...

  4. Ubuntu 16.04下使用Wine安装Windows版的微信(不太完美)

    说明: 真的不太完美,别试了:除了需要安装额外的输入法之后,无法上传图片和间接性的BUG出现等等问题. 建议安装网页版的微信:http://www.cnblogs.com/EasonJim/p/711 ...

  5. java计算年龄

    精确到天计算年龄 public static int getAgeByCardId(String card) throws Exception { Integer len = card.length( ...

  6. maven打包自动配置数据库链接信息

    pom.xml加入下面代码 <profiles> <profile> <id>dev</id> <activation> <activ ...

  7. 计算广告、推荐系统论文以及DSP综述

    http://www.huxmarket.com/detail/2966 DSP场景假定前提: 以CTR预估为例,向广告主以CPC(OCPC)方式收费,向ADX以CPM方式付费.投放计划受预算限制,在 ...

  8. hdu 5389 Zero Escape (dp)

    题目:http://acm.hdu.edu.cn/showproblem.php? pid=5389 题意:定义数根:①把每一位上的数字加起来得到一个新的数,②反复①直到得到的数仅仅有1位.给定n,A ...

  9. 你所不知道的库存超限做法 服务器一般达到多少qps比较好[转] JAVA格物致知基础篇:你所不知道的返回码 深入了解EntityFramework Core 2.1延迟加载(Lazy Loading) EntityFramework 6.x和EntityFramework Core关系映射中导航属性必须是public? 藏在正则表达式里的陷阱 两道面试题,带你解析Java类加载机制

    你所不知道的库存超限做法 在互联网企业中,限购的做法,多种多样,有的别出心裁,有的因循守旧,但是种种做法皆想达到的目的,无外乎几种,商品卖的完,系统抗的住,库存不超限.虽然短短数语,却有着说不完,道不 ...

  10. 利用泛型和反射,管理配置文件,把Model转换成数据行,并把数据行转换成Model

    利用泛型和反射,管理配置文件,把Model转换成数据行,并把数据行转换成Model   使用场景:网站配置项目,为了便于管理,网站有几个Model类来管理配置文件, 比如ConfigWebsiteMo ...