方式一、使用Homebrew安装FFmpeg
1. 安装Homebrew
如果你的Mac上没有安装Homebrew,那么就先来安装Homebrew吧!步骤如下:
- 打开Terminal,执行如下命令
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
- 如果出现以下报错:
或者出现类似报错,可以尝试使用国内源进行安装。curl: (28) Failed to connect to raw.githubusercontent.com port 443 after 75013 ms: Operation timed out
- 使用国内源进行安装,只需执行如下命令:
然后按照提示进行操作就可以了,这个过程中需要多次输入密码(就是你电脑的开机密码);/bin/zsh -c "$(curl -fsSL https://gitee.com/cunkai/HomebrewCN/raw/master/Homebrew.sh)"
- 然后耐心等待,如果没有任何意外,就会安装成功,并且提示重启Terminal;此时,Homebrew就安装成功了;
2. 安装FFmpeg
- 重新启动Terminal,执行如下命令:
brew install ffmpeg
- 此时会下载很多包,可能会出现以下错误:
fatal: not in a git directory Error: Command failed with exit 128: git
- 如果出现了上述错误,可以执行
此时Terminal会告诉你,git认为你的homebrew-core目录和homebrew-cask目录是不安全的:brew -v
你可以执行其中的Homebrew 3.6.7-32-g31758ea fatal: unsafe repository ('/usr/local/Homebrew/Library/Taps/homebrew/homebrew-core' is owned by someone else) To add an exception for this directory, call: git config --global --add safe.directory /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core Homebrew/homebrew-core (no Git repository) fatal: unsafe repository ('/usr/local/Homebrew/Library/Taps/homebrew/homebrew-cask' is owned by someone else) To add an exception for this directory, call: git config --global --add safe.directory /usr/local/Homebrew/Library/Taps/homebrew/homebrew-cask Homebrew/homebrew-cask (no Git repository)
和git config --global --add safe.directory /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core
来将你的homebrew-core目录和homebrew-cask目录配置为git认为安全的目录。git config --global --add safe.directory /usr/local/Homebrew/Library/Taps/homebrew/homebrew-cask
- 此时,重新执行
如果没有意外,就可以成功安装FFmpeg了。brew install ffmpeg
- 安装完成后,可以在Terminal中执行如下命令
来查看FFmpeg版本信息,返回版本信息则说明已经安装成功ffmpeg -version
ffmpeg version 5.1.2 Copyright (c) 2000-2022 the FFmpeg developers built with Apple clang version 14.0.0 (clang-1400.0.29.102) configuration: --prefix=/usr/local/Cellar/ffmpeg/5.1.2 --enable-shared --enable-pthreads --enable-version3 --cc=clang --host-cflags= --host-ldflags= --enable-ffplay --enable-gnutls --enable-gpl --enable-libaom --enable-libbluray --enable-libdav1d --enable-libmp3lame --enable-libopus --enable-librav1e --enable-librist --enable-librubberband --enable-libsnappy --enable-libsrt --enable-libtesseract --enable-libtheora --enable-libvidstab --enable-libvmaf --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libxvid --enable-lzma --enable-libfontconfig --enable-libfreetype --enable-frei0r --enable-libass --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libspeex --enable-libsoxr --enable-libzmq --enable-libzimg --disable-libjack --disable-indev=jack --enable-videotoolbox libavutil 57. 28.100 / 57. 28.100 libavcodec 59. 37.100 / 59. 37.100 libavformat 59. 27.100 / 59. 27.100 libavdevice 59. 7.100 / 59. 7.100 libavfilter 8. 44.100 / 8. 44.100 libswscale 6. 7.100 / 6. 7.100 libswresample 4. 7.100 / 4. 7.100 libpostproc 56. 6.100 / 56. 6.100
方式二、通过官网安装FFmpeg
-
进入官网Download FFmpeg
-
出现如下页面:
-
点击苹果标识,进入如下页面:
-
点击红框内按钮,开始下载压缩包;
-
下载完成后解压,得到如下图所示的图标:
-
点击打开即可进入到终端界面,可运行FFmpeg命令;