关于mac下编译ffmpeg的方法有很多方法,这里介绍一种亲测的简单方法
软件版本
OS版本:OS X EI Capitan 10.11.5
FFMPEG源码版本:http://ffmpeg.org/releases/ffmpeg-3.1.4.tar.bz2
编译步骤
1、安装XCode
安装Xcode,直接在APP Store里下载安装最新版,确认Command Line Tools是否可用,不然无法使用gcc命令,安装好gcc的时候git也被安装好
2、安装Homebrew
http://blog.youkuaiyun.com/shirnyhelloworld/article/details/52831424
关于home-brew安装之前也写了一个说明,可以参考一下。homebrew可以很方便的安装和卸载开源软件。
3、安装ffmpeg相关依赖包
ffmpeg需要的依赖包几乎都可以通过brew install安装,但有些是非开源的,也不是全部都需要安装,根据自己的需要可以有选择的安装。
我选择的依赖包如下:
192:libaacplus-2.0.2 shirny$ brew install automake faac fdk-aac lame libass libtool libvorbis libvpx libvo-aacenc opencore-amr openjpeg opus sdl schroedinger shtool speex texi2html theora wget x264 xvid yasm
关于安装libaacplus,我尝试了很多方法在mac上都是失败,所以干脆放弃不安装了,如果有好的方法希望能交流一下,这里提供一个libaacplus-2.0.2.tar.gz的获取路径:
192:ffmpeg-3.1.4 shirny$ wget http://ffmpeg.gusari.org/uploads/libaacplus-2.0.2.tar.gz
4、编译ffmpeg
进入ffmpeg-3.1.4.tar.bz2解压后的目录,直接运行./configure 加选项可以来编译ffmpeg,但是有可能会在openjpeg这个依赖包上报错,网上有个解决方法可供参考,找到openjpeg的路径,如果是通过homebrew安装的话,路径默认是”/usr/local/Cellar”,我的路径是:
192:openjpeg-2.1 shirny$ pwd
/usr/local/Cellar/openjpeg/2.1.2/include/openjpeg-2.1
所以添加以下语句:
export CFLAGS="-I/usr/local/Cellar/openjpeg/2.1.2/include/openjpeg-2.1"
接着进入ffmpeg-3.1.4.tar.bz2解压后的目录,添加编译选项,将之前的依赖包和ffmpeg源码一起编译,如果需要“SDL+X264”,可以加上该选项:
192:ffmpeg-3.1.4 shirny$ ./configure -