2016最新FFmpeg-iOS静态库编译

一直在电商圈混迹,最近想自己找找视频图像方面的项目做做练手,于是打算从FFmpeg这个比较流行的框架开始,但是竟然因为一个“GNU assembler not found, install/update gas-preprocessor”问题,困扰了我一整天,所以写篇博客记录编译过程。希望能帮到打算做尝试的朋友们。

下载gas-preprocessor.pl

github地址:https://github.com/libav/gas-preprocessor
官方最新地址,github上也有以下其他的地址,但是其gas-preprocessor是几年前的,这种日期的gas-preprocessor在编译的时候会出现文章开始说的“GNU assembler not found, install/update gas-preprocessor”的问题。所以一定要下载最新的。

  1. 复制gas-preprocessor.pl到/usr/sbin下;
  2. 修改文件权限,终端输入以下信息:chmod 777 /usr/sbin/gas-preprocessor.pl

    修改gas-preprocessor, 打开gas-preprocessor根据项目需求进行改动

use strict;

# Apple's gas is ancient and doesn't support modern preprocessing features like
# .rept and has ugly macro syntax, among other things. Thus, this script
# implements the subset of the gas preprocessor used by x264 and ffmpeg
# that isn't supported by Apple's gas.

下载安装yasm

下载yasm最新版本:http://www.tortall.net/projects/yasm/releases/
cd 进入你的yasm最新版中,执行以下命令行代码:

MacBook-Pro:FFmpeg-iOS-build-script-master wenzhan$ ./configure
MacBook-Pro:FFmpeg-iOS-build-script-master wenzhan$ make
MacBook-Pro:FFmpeg-iOS-build-script-master wenzhan$ sudo make install

下载FFmpeg最新版本

FFmpeg官方地址:http://ffmpeg.org/download.html#build-mac
下载完成后,将FFmpeg放入到yasm目录下。

运行build-ffmpeg.sh脚本

下载build-ffmpeg.sh:http://download.csdn.net/detail/perfect_promise/9435587
cd进入下载build-ffmpeg.sh目录下,执行代码:

MacBook-Pro:FFmpeg-iOS-build-script-master wenzhan$./build-preprocessor.sh

展示一下编译结束的命令行:

building fat binaries...
lipo -create /Users/wenzhan/Downloads/FFmpeg-iOS-build-script-master/thin/arm64/lib/libavcodec.a /Users/wenzhan/Downloads/FFmpeg-iOS-build-script-master/thin/armv7/lib/libavcodec.a -output FFmpeg-iOS/lib/libavcodec.a
lipo -create /Users/wenzhan/Downloads/FFmpeg-iOS-build-script-master/thin/arm64/lib/libavdevice.a /Users/wenzhan/Downloads/FFmpeg-iOS-build-script-master/thin/armv7/lib/libavdevice.a -output FFmpeg-iOS/lib/libavdevice.a
lipo -create /Users/wenzhan/Downloads/FFmpeg-iOS-build-script-master/thin/arm64/lib/libavfilter.a /Users/wenzhan/Downloads/FFmpeg-iOS-build-script-master/thin/armv7/lib/libavfilter.a -output FFmpeg-iOS/lib/libavfilter.a
lipo -create /Users/wenzhan/Downloads/FFmpeg-iOS-build-script-master/thin/arm64/lib/libavformat.a /Users/wenzhan/Downloads/FFmpeg-iOS-build-script-master/thin/armv7/lib/libavformat.a -output FFmpeg-iOS/lib/libavformat.a
lipo -create /Users/wenzhan/Downloads/FFmpeg-iOS-build-script-master/thin/arm64/lib/libavutil.a /Users/wenzhan/Downloads/FFmpeg-iOS-build-script-master/thin/armv7/lib/libavutil.a -output FFmpeg-iOS/lib/libavutil.a
lipo -create /Users/wenzhan/Downloads/FFmpeg-iOS-build-script-master/thin/arm64/lib/libswresample.a /Users/wenzhan/Downloads/FFmpeg-iOS-build-script-master/thin/armv7/lib/libswresample.a -output FFmpeg-iOS/lib/libswresample.a
lipo -create /Users/wenzhan/Downloads/FFmpeg-iOS-build-script-master/thin/arm64/lib/libswscale.a /Users/wenzhan/Downloads/FFmpeg-iOS-build-script-master/thin/armv7/lib/libswscale.a -output FFmpeg-iOS/lib/libswscale.a
Done

文件夹中会多出一个FFmpeg-iOS的静态库文件,这就是我们编译要得到的库,如下
2016最新FFmpeg-iOS静态库编译_第1张图片

将FFmpeg拖入项目中就可以使用了。

你可能感兴趣的:(开发)