Homebrew 是程序包管理器. 在MacOS上使用 Homebrew 安装FFmpeg 很简单。可以将其视为 linux 上的 apt-get 等效。
安装命令如下:
$ 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' ' ')
这个是在 github上讨论出来最完整的脚本
https://gist.github.com/Piasy/b5dfd5c048eb69d1b91719988c0325d8
安装之后的 FFmpeg信息
% brew info ffmpeg 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)
错误解决方案
% 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
需要删除 --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"
HOW TO INSTALL FFMPEG ON MACOS?