Enabling libfdk_aac in ffmpeg installed with Homebrew
Solution 1
Homebrew v2.0 dropped all of the extra options that are not explicitly enabled in each formulae. So the --with
options no longer work if you use the core Homebrew formulae.
Instead you can use a third-party repository (or "tap") such as homebrew-ffmpeg. This tap was created in response to the removal of the options from the core formulae.
Enable it then install ffmpeg
:
brew tap homebrew-ffmpeg/ffmpeg
brew install homebrew-ffmpeg/ffmpeg/ffmpeg --with-fdk-aac
You can see a list of additional options with:
brew options homebrew-ffmpeg/ffmpeg/ffmpeg
It's recommended to install a recent build from the git master branch. You can do so with the --HEAD
option:
brew install homebrew-ffmpeg/ffmpeg/ffmpeg --with-fdk-aac --HEAD
Solution 2
You could use MacPorts
to install ffmpeg with +nonfree
option.
In summary, you'll need to:
-
Install Xcode tools. Try
xcode-select --install
, or check Apple's developer website. -
Install MacPorts using the right pkg file for your MacOs release, or use one of the other options shown in the MacPorts installation guide.
-
Install ffmpeg using MacPorts:
$ sudo port install ffmpeg +nonfree
Which will ask:
---> Computing dependencies for ffmpeg
The following dependencies will be installed:
Xft2
XviD
aom
autoconf
autoconf-archive
automake
brotli
bzip2
cairo
cctools
curl-ca-bundle
dav1d
db48
expat
fontconfig
freetype
fribidi
gd2
gdbm
gdk-pixbuf2
gettext
gettext-runtime
gettext-tools-libs
giflib
glib2
gmake
gmp
gnutls
gobject-introspection
graphite2
graphviz
gts
harfbuzz
icu
jasper
jbigkit
lame
lcms2
libLASi
libass
libbluray
libde265
libedit
libfdk-aac
libffi
libheif
libiconv
libidn2
libjpeg-turbo
libmodplug
libnetpbm
libogg
libopus
libpixman
libpng
librsvg
libsdl2
libtasn1
libtextstyle
libtheora
libtool
libunistring
libvorbis
libvpx
libxml2
libxslt
lz4
m4
nasm
ncurses
nettle
openjpeg
openssl
openssl3
ossp-uuid
p11-kit
pango
pcre
perl5.28
perl5.30
pkgconfig
py39-beaker
py39-importlib-metadata
py39-mako
py39-markdown
py39-markupsafe
py39-setuptools
py39-zipp
python39
python3_select
python_select
rav1e
readline
shared-mime-info
soxr
speex
sqlite3
texinfo
tiff
urw-fonts
vala
webp
x264
x265
xorg-libX11
xorg-libXau
xorg-libXaw
xorg-libXdmcp
xorg-libXext
xorg-libXmu
xorg-libXt
xorg-libice
xorg-libpthread-stubs
xorg-libsm
xorg-libxcb
xorg-xcb-proto
xorg-xcb-util
xorg-xorgproto
xpm
xrender
xz
zimg
zlib
zstd
zvbi
Continue? [Y/n]: y
That will install all of those. The libfdk-aac
codec will be built optimised for your machine, as well as ffmpeg
. All of that takes some time.
Result:
$ ffmpeg -codecs | grep libfdk
AAC (Advanced Audio Coding) (decoders: aac aac_fixed aac_at libfdk_aac ) (encoders: aac aac_at libfdk_aac )
To see full codec list and supported formats:
$ ffmpeg -codecs
$ ffmpeg -formats
The other option would be to compile it yourself and choose whatever options you want.
![RocketNuts](https://i.stack.imgur.com/Dm2v8.png?s=256&g=1)
RocketNuts
Updated on June 14, 2022Comments
-
RocketNuts about 2 years
On macOs I always used to install or update ffmpeg through Homebrew. I use the libfdk_aac audio codec a lot so I always did this:
brew reinstall ffmpeg --with-fdk-aac
For some reason, since one or two brew updates, ffmpeg can no longer be installed with libfdk_aac.
When converting a video and using
-acodec libfdk_aac
which has been working fine for years, I now get:Unknown encoder 'libfdk_aac'
Is there a way to fix this?
-
RocketNuts over 5 yearsThanks! I'll be going with @llogan's ffmpeg tap solution for now, as it allows me to stick to Homebrew. But I had zero knowledge about MacPorts and it certainly looks useful, I may be using that more in the future as well, much appreciated for pointing that out!
-
Nicolas BADIA about 4 yearsThanks, libfdk_aac was properly installed for me with the git master branch of ffmpeg
-
Will Ashworth over 3 yearsSaved my bacon. Thanks for this 💯
-
FuegoJohnson over 3 yearsWanted to mention that this method still works on Big Sur in 2021. Appreciated! Much easier than compiling on Windows.
-
somatic over 2 yearsworked even on old 10.13 system, after two days of running down all the wrong rabbit holes, this did it!