Mac FFmpeg x265, aac, ffplay编译安装

来源:互联网 发布:python replace into 编辑:程序博客网 时间:2024/04/29 15:23

1. 通过HomeBrew安装

最简单,最方便的方法是通过HomeBrew安装,
HomeBrew也是通过下载源代码,进行编译安装的,所以不想麻烦通过HomeBrew是明智的选择。

1.1安装HomeBrew

如果HomeBrew没有安装,可以通过下面命令安装:

/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

1.2 安装完全FFmpeg

brew install ffmpeg –with-fdk-aac –with-ffplay –with-freetype –with-libass –with-libquvi –with-libvorbis –with-libvpx –with-opus –with-x265


2. 基本安装方法

如果不需要安装额外的库文件(比如x264, vpx等),直接进行编译即可,也不需要额外的配置。

2.1 下载源代码

git clone https://git.ffmpeg.org/ffmpeg.git ffmpeg

这个就不多说了,随你怎么下吧

2.2 编译

./configure; make && sudo make install

PS:有一点需要说明的是这种方法编译后是没有ffplay的。


3. 完全安装

需要说明的是,下面这些额外的库文件可以通过Homebrew安装,也可以通过源代码编译,这没有不同,最后只需要在编译ffmpeg时加入对应的参数即可。

3.1 Pkg-config & GLib

Pkg-config用于检查包依赖,GLib是其必须的依赖库。

编译GLib

(1)可以从GNU下载源代码
(2)修改stpncpy.c
add “#undef stpncpy” just before “#ifndef weak_alias”
(3)Compile

LIBFFI_CFLAGS=-I/usr/include/ffi LIBFFI_LIBS=-lffi ./configure;make && sudo make install

编译Pkg-config

(1)下载源代码
https://pkg-config.freedesktop.org/releases/

(2) Compile

GLIB_CFLAGS="-I/usr/local/include/glib-2.0 -I/usr/local/lib/glib-2.0/include" GLIB_LIBS="-lglib-2.0 -lgio-2.0" ./configure --with-pc-path="/usr/X11/lib/pkgconfig:/usr/X11/share/pkgconfig:/usr/lib/pkgconfig:/usr/local/lib/pkgconfig"

3.2 Yasm

Yasm是C汇编优化的东西,能够大幅提高ffmpeg的执行效率。
(1)下载源码
http://yasm.tortall.net/Download.html

(2)编译

./configure --enable-python; make && sudo make install

PS:这个直接Homebrew安装好了

3.3 x264

sudo git clone git://git.videolan.org/x264.gitcd x264sudo ./configure --enable-shared --prefix=/usr/localsudo makesudo make installcd ..

ffmpeg对应编译参数:

--enable-gpl --enable-libx264

3.4 libvpx

这个就是Google推出VP8,VP9编码

sudo wget http://webm.googlecode.com/files/libvpx-v0.9.7-p1.tar.bz2sudo tar xvjf libvpx-v0.9.7-p1.tar.bz2cd libvpx-v0.9.7-p1sudo ./configure --enable-shared --prefix=/usr/localsudo makesudo make installcd ..

ffmpeg对应编译参数

--enable-libvpx

PS:这个直接Homebrew安装吧

brew install libvpx

3.5 其它

​x265

H.265 编码器。

--enable-gpl --enable-libx265

​fdk-aac

AAC 音频编码器

 --enable-libfdk-aac

​libvorbis

Vorbis 音频编码器 .依赖于​libogg.

--enable-libvorbis

​libopus
Opus 音频编码器.

--enable-libopus

​LAME
MP3编码器

 --enable-libmp3lame

​libass

ASS字母渲染器

 --enable-libass

3.6 ffmpeg完整编译命令实例

(1)config
设置prefix = ./build,编译到当前build目录下

mkdir build./configure  --prefix=./build --enable-gpl --enable-nonfree --enable-libass --enable-libfdk-aac --enable-libfreetype --enable-libmp3lame --enable-libopus --enable-libtheora --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libx265 --enable-libxvid

这里写图片描述

只要不出现config错误,查看config.log就说明config成功

(2)编译

make -j4

此不执行完毕后,基本算是成功。
这里写图片描述

(3)安装
把编译的文件复制config 阶段设置的prefix目录

make install

下面是我自己build目录文件:

这里写图片描述

自此,大功告成!
Congratulation!
^_^


4. 参考文献

[1] FFmpeg Wiki

0 0
原创粉丝点击