在 iOS上 编译 FFmpeg

FFmpeg是一套可以用来记录、转换数字音频、视频,并能将其转化为流的开源计算机程序。采用LGPL或GPL许可证。它提供了录制、转换以及流化音视频的完整解决方案。

 

 准备条件

  1. 安装 yasm。 解压后

     cd yasm-1.2.0

     ./configure

     make

     make install

  2. 到https://github.com/libav/gas-preprocessor下载 gas-preprocessor.pl 文件,

    复制gas-preprocessor.pl到/usr/bin下,

    修改文件权限 chmod 777 /usr/local/bin/gas-preprocessor.pl


开始搭建

  1. 下载脚本:https://github.com/kewlbear/FFmpeg-iOS-build-script

  2. 解压,找到文件 build-ffmpeg.sh

  3. 执行服本文件:./build-ffmpeg.sh, 由于本人没有事先安装Yasm

    095058_3nEA_2547410.png

    101505_lB1U_2547410.png

    脚本则会自动从github中把ffmpeg源码下到本地并开始编译。 编译结束后,文件目录如下:

    154824_9DpA_2547410.png

  4. 编译完成后,终端进入FFmpeg-iOS-build-script目录,然后输入./build-ffmpeg.sh lipo,这个命令是将.a文件合并成一个

  5. 把ffmpeg-iOS文件加入到工程中

  6. libz.dylib libbz2.dylib libiconv.dylib是必须要导入的

     

运行编译

  1. 编译报 include“libavformat/avformat.h” file not found 错误。在Build Settings中找到Search Paths,设置Header Search Pahts 和 Library Search Paths。修改Header search paths 里的路径:$(PROJECT_DIR)/FFmpeg-iOS/include

  2. Directly in the engineering of "TARGETS" - > "BuildSettings" - > "Other Linker Flags" click on the "+" to add a "- liconv" item, if you have any questions, welcome to leave a message

    Undefined symbols for architecture i386:
      "_iconv", referenced from:
          _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)
      "_iconv_open", referenced from:
          _avcodec_open2 in libavcodec.a(utils.o)
          _avcodec_decode_subtitle2 in libavcodec.a(utils.o)
    ld: symbol(s) not found for architecture i386
    clang: error: linker command failed with exit code 1 (use -v to see invocation)

 

-----------------我是分割线----------------------

-- 2016 09 19 编辑

安装yasm出现问题,首先到官网下载 (我下载的 yasm-1.3.0.tar.gz)解压后,cd 到目录执行:

1. cd ...

2. ./configure

3. make

4. sudo make install(我原来执行的make install 总是不成功)

转载于:https://my.oschina.net/asjoker/blog/614794

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值