第一步:下载gas-preprocessor
1.1 下载地址:https://github.com/libav/gas-preprocessor
1.2 拷贝gas-preprocessor.pl 到/usr/sbin目录,命令为:sudo -i cp gas-preprocessor.pl /usr/sbin
1.3 修改gas-preprocessor.pl 文件权限,命令为:chmod 777 /usr/sbin/gas-preprocessor.pl
注意:如果执行1.2出现 Operation not permitted,该如何操作?
* 系统开启了SIP(System Integrity Protection) ,root 权限也无法修改/usr/sbin 目录
* 如何禁止SIP,重启电脑,按住Command+R,进入Recovery模式,打开Utilities下的终端
* 在终端中输入csrutil disable,正常启动电脑即可。
* 如何查看/usr/sbin目录是否拷贝成功,Shift+Command+G,输入路径/usr/sbin进入目录查看即可
第二步:下载编译脚本
下载地址:https://github.com/kewlbear/FFmpeg-iOS-build-script
第三步:下载FFmpeg
下载地址:https://github.com/FFmpeg/FFmpeg
第四步:编译
将下载的 FFmpeg 放在编译脚本目录下,执行 sh build-ffmpeg.sh,等待完成。
不出意外的话会得到如图文件夹

即为我们需要的lib包和头文件。
第五步:导入
5.1 将编译好的FFmpeg-iOS包拖入到项目中

5.2 设置Header Search Path 如图:

5.3 引用头文件测试:

编译未报错。
网友评论