FFmpeg在iOS上完美编译

来源:互联网 发布:seo常用的工具 编辑:程序博客网 时间:2024/05/29 04:08

http://www.cocoachina.com/ios/20150514/11827.html

招聘信息:
  • iOS工程师
  • iOS软件工程师
  • 手游JAVA 服务器端主程
  • cocos2dx手游客户端主程
  • iOS开发工程师
  • iOS研发工程师
  • 菜鸟快递员SDK岗位(iOS/Android)
  • 交互设计师(UE/产品)
  • Android高级开发工程师(中国排名第一的企业级移动互联网云计算公司 和创科技 红圈营销)
  • iOS高级开发工程师(中国排名第一的企业级移动互联网云计算公司 和创科技 红圈营销)
  • iOS工程师
 

1.jpg

最近刚接触ffmpeg,找了很多相关的编译资料,都没有编译成功,前几天在 github上找到一个脚本(https://github.com/kewlbear/FFmpeg-iOS-build-script),就可完美编译

准备条件

  • 先下载文件:https://github.com/libav/gas-preprocessor

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

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

  • 安装yasm

具体步骤如下:

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

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

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

如下:

MAC:FFmpeg-iOS-build-script-master-2 jinsonglnan$ ./build-ffmpeg.sh Yasm not foundHomebrew not found. Trying to install...Whoops, the Homebrew installer has moved! Please instead run:ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"Also, please ask wherever you got this link from to update it to the above.Trying to install Yasm..../build-ffmpeg.sh: line 67: brew: command not found

意思就是说,没有yasm, 看到提示执行 ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"安装

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

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

6.添加一个头文件引用 #include "avformat.h"

添加一个api语句:av_register_all();给一个类文件.m后缀改为.mm,开启混编模式。

运行工程,如果没有报错,则表明编译成功

7.其他注意细节 

编译的时候报错: 'libavcodec/avcodec.h' file not found ,修改Header search paths 里的路径:$(PROJECT_DIR)/FFmpeg-iOS/include

加入External libraries:

libz.dyliblibbz2.dyliblibiconv.dylib

8.编译好,写了个demo:点此下载

搜索CocoaChina微信公众号:CocoaChina
微信扫一扫
订阅每日移动开发及APP推广热点资讯
公众号:
CocoaChina
我要投稿  收藏文章
27
上一篇:iOS开发中两个常见问题的处理
下一篇:源码推荐(5.14):TYAttributedLabel简单易用的富文本,高仿iOS 系统计算器(基本功能)

0 0
原创粉丝点击