Skip to content

Instantly share code, notes, and snippets.

@stevemclaugh
Last active April 4, 2024 16:06
Show Gist options
  • Save stevemclaugh/aa96cb5d8add3bfded51e0e586179959 to your computer and use it in GitHub Desktop.
Save stevemclaugh/aa96cb5d8add3bfded51e0e586179959 to your computer and use it in GitHub Desktop.
Instructions for installing the command-line media conversion program FFmpeg with MP3 support on macOS.

Install FFmpeg with MP3 support on macOS

Initial Setup

If Homebrew is already installed, skip to "Install FFmpeg" below.

Launch Terminal in macOS, located at /Applications/Utilities/Terminal.app. To install a bundle of command-line tools provided by Apple, paste the following line into the terminal window and press return. When prompted, click "Install," then "Agree."

xcode-select --install

Run the following command to install the Homebrew package manager. Enter your password at the prompt to proceed.

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

Next, enter this command to update Homebrew.

brew update

If Homebrew returns an error, enter the following command to give it the permissions it expects.

sudo chown $(whoami):admin /usr/local && sudo chown -R $(whoami):admin /usr/local

Install FFmpeg

First, run the following command to remove FFmpeg in case it's already installed.

brew uninstall --force --ignore-dependencies ffmpeg

Now let's install the required compilation utilities and media codecs.

brew install automake fdk-aac git lame libass libtool libvorbis libvpx opus sdl shtool texi2html theora wget x264 xvid yasm

Next we'll download FFmpeg's source code and compile it before installing. Although it's faster to install FFmpeg through Homebrew, that version can't read or write MP3 files.

Enter the following commands one at a time; note that the third line is very long. After the last command you will be prompted to enter your admin password.

git clone http://source.ffmpeg.org/git/ffmpeg.git ffmpeg

cd ffmpeg

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

make && sudo make install

The final step above will take 5 or 10 minutes to complete. When it's done, open a new terminal window and enter the following to view FFmpeg's manual.

man ffmpeg

If you've made it this far, you should be all set. Press q to close the manual.

Here's a basic FFmpeg command to convert a file called input.wav on your desktop to a 320Kbps MP3 called output.mp3.

cd ~/Desktop

ffmpeg -i input.wav -ab 320k output.mp3
@marcosabel
Copy link

The configure line doesn't work for me with my current setup (Apple Silicon, 04/2024, master branch of FFmpeg). The configure script doesn't find the required libraries installed with Brew.

It might well be a particular problem with my setup, but in case anyone else hits the same problem, here is the configure line that works for me:

./configure  --prefix=/usr/local --enable-gpl --enable-nonfree --enable-libass --enable-libfdk-aac --enable-libfreetype --enable-libmp3lame --enable-libopus --enable-libtheora --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libxvid --extra-ldflags="-L/opt/homebrew/lib"  --extra-cflags=-I/opt/homebrew/include

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment