FFmpeg在iOS上完美编译

最近刚接触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 found

Homebrew 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.dylib

libbz2.dylib

libiconv.dylib


8.编译好,写了个demo

GitHub:  https://github.com/baitxaps/FFmpegDemo

CSDN:  http://download.csdn.net/detail/baitxaps/8657935


  • 1
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 6
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值