Record macOS CoreAudio Input Using FFmpeg
This article provides a straightforward, step-by-step guide on how to capture audio from any CoreAudio input device on macOS using the FFmpeg command-line tool. You will learn how to locate your system’s audio input devices using the AVFoundation framework and run the precise commands required to record high-quality audio directly to your local storage.
Step 1: Install FFmpeg
To get started, ensure you have FFmpeg installed on your Mac. The easiest way to install it is via Homebrew. Open your Terminal and run:
brew install ffmpegStep 2: List Available CoreAudio Devices
macOS handles audio and video devices through the AVFoundation framework. Before recording, you must identify the index number or the exact name of your audio input device (such as a built-in microphone or an external USB interface).
Run the following command to list all available input devices:
ffmpeg -f avfoundation -list_devices true -i ""Look at the Terminal output under the “[AVFoundation input device list]” section. You will see a list of video devices followed by audio devices. Note the name or the index number of the audio device you want to capture. For example:
[AVFoundation input device list]
[AVFoundation @ 0x123456789] AVFoundation video devices:
[AVFoundation @ 0x123456789] [0] FaceTime HD Camera
[AVFoundation @ 0x123456789] AVFoundation audio devices:
[AVFoundation @ 0x123456789] [0] Built-in Microphone
[AVFoundation @ 0x123456789] [1] External Microphone
Step 3: Capture Audio from the Device
To record audio, use the AVFoundation format
(-f avfoundation). In the input option (-i),
specify the audio device using the syntax
":<device_index>" or
":<device_name>". The colon : tells
FFmpeg to ignore video input and select only the audio stream.
Option A: Recording by Device Index
If your desired audio device is listed as index 0 (e.g.,
Built-in Microphone), run:
ffmpeg -f avfoundation -i ":0" output.wavOption B: Recording by Device Name
Alternatively, you can specify the exact name of the device in quotes:
ffmpeg -f avfoundation -i ":Built-in Microphone" output.wavStep 4: Stop the Recording
To stop the audio capture at any time, press q or
Ctrl + C in your Terminal window. FFmpeg will safely close
the file and save your recording.
Advanced Recording Options
You can customize the output quality, format, and channels by appending additional flags to your command:
Record to MP3 with a specific sample rate and channels:
ffmpeg -f avfoundation -i ":0" -ar 44100 -ac 2 output.mp3(This sets the audio sample rate to 44.1 kHz and the channels to 2 for stereo sound).
Record to uncompressed WAV format:
ffmpeg -f avfoundation -i ":0" -c:a pcm_s16le output.wav