基础安装
Homebrew 是 MacOS 上的程序包管理器, 可以将其视为 Linux 上 apt-get
的等效工具。通过 Homebrew 安装 FFmpeg 非常简单, 使用以下命令即可完成基础安装
brew install ffmpeg
完整安装脚本 (支持所有依赖项)
截止至 2020 年 3 月 25 日, MacOS + Homebrew 的 FFmpeg 安装已禁用本机依赖项支持。如果需要构建带有其他库的完整版本, 可以使用以下脚本
brew install nasm pkg-config texi2html aom fontconfig freetype frei0r gnutls lame libass libbluray libsoxr libvorbis libvpx opencore-amr openjpeg opus rtmpdump rubberband sdl2 snappy speex tesseract theora x264 x265 xvid xz
brew uninstall --force --ignore-dependencies ffmpeg
brew install chromaprint amiaopensource/amiaos/decklinksdk
brew tap homebrew-ffmpeg/ffmpeg
brew install ffmpeg
brew cask install xquartz
brew upgrade homebrew-ffmpeg/ffmpeg/ffmpeg $(brew options homebrew-ffmpeg/ffmpeg/ffmpeg | grep -vE '\s' | grep -- '--with-' | grep -vi chromaprint | grep -vi game-music-emu | tr '\n' ' ')
该脚本来源于社区讨论, 被认为是最完整的安装脚本。原始链接: brew install ffmpeg with all options
安装后信息
安装完成后, 可以使用以下命令查看 FFmpeg 的详细信息
brew info ffmpeg
示例输出 (截至 2020 年 8 月 30 日)
ffmpeg: stable 4.3.1 (bottled), HEAD
Play, record, convert, and stream audio and video
https://ffmpeg.org/
/usr/local/Cellar/ffmpeg/4.3.1-with-options_2 (267 files, 55MB) *
Built from source on 2020-08-30 at 02:10:22 with: --with-decklink --with-fdk-aac --with-librsvg --with-libsoxr --with-libssh --with-tesseract --with-libvidstab --with-opencore-amr --with-openh264 --with-openjpeg --with-openssl --with-rav1e --with-rubberband --with-webp --with-zeromq --with-zimg --with-srt --with-libvmaf --with-libxml2 --with-libbluray --with-libbs2b --with-libcaca --with-libgsm --with-libmodplug --with-openssl@1.1 --with-rtmpdump --with-speex --with-two-lame --with-wavpack --with-xvid
From: https://github.com/Homebrew/homebrew-core/blob/HEAD/Formula/ffmpeg.rb
License: GPL-2.0
==> Dependencies
Build: nasm , pkg-config , texi2html
Required: aom , dav1d , fontconfig , freetype , frei0r , gnutls , lame , libass , libbluray , libsoxr , libvidstab , libvorbis , libvpx , opencore-amr , openjpeg , opus , rav1e , rtmpdump , rubberband , sdl2 , snappy , speex , srt , tesseract , theora , webp , x264 , x265 , xvid , xz
==> Options
--HEAD
Install HEAD version
==> Analytics
install: 92,312 (30 days), 392,610 (90 days), 1,286,857 (365 days)
install-on-request: 73,930 (30 days), 309,668 (90 days), 972,270 (365 days)
build-error: 0 (30 days)
常见问题及解决方案
libclang_rt.ubsan_osx_dynamic.dylib
错误
错误信息
% ffmpeg
dyld: Library not loaded: @rpath/libclang_rt.ubsan_osx_dynamic.dylib
Referenced from: /usr/local/opt/game-music-emu/lib/libgme.0.dylib
Reason: image not found
zsh: abort ffmpeg
解决方法: 重新安装 FFmpeg, 并移除 --with-game-music-emu
选项
libxml2
依赖路径问题
安装过程中可能出现以下提示
==> Caveats
==> libxml2
libxml2 is keg-only, which means it was not symlinked into /usr/local,
because macOS already provides this software and installing another version in
parallel can cause all kinds of trouble.
If you need to have libxml2 first in your PATH run:
echo 'export PATH="/usr/local/opt/libxml2/bin:$PATH"' >> ~/.zshrc
For compilers to find libxml2 you may need to set:
export LDFLAGS="-L/usr/local/opt/libxml2/lib"
export CPPFLAGS="-I/usr/local/opt/libxml2/include"
For pkg-config to find libxml2 you may need to set:
export PKG_CONFIG_PATH="/usr/local/opt/libxml2/lib/pkgconfig"
解决方法: 按照提示执行以下命令, 最后再重新运行安装脚本
echo 'export PATH="/usr/local/opt/libxml2/bin:$PATH"' >> ~/.zshrc
export LDFLAGS="-L/usr/local/opt/libxml2/lib"
export CPPFLAGS="-I/usr/local/opt/libxml2/include"
export PKG_CONFIG_PATH="/usr/local/opt/libxml2/lib/pkgconfig"
原文