Capture Audio from macOS Interface Using FFmpeg

Capturing audio from a specific audio interface on macOS using FFmpeg is a straightforward process handled through the native AVFoundation framework. This guide demonstrates how to list your connected input hardware, identify the target device's index, and execute the exact FFmpeg command needed to record high-quality audio directly to a file.

1. List Available Audio Devices

macOS uses the avfoundation input device in FFmpeg. Before recording, you must find the specific device index assigned to your audio interface.

Open Terminal and run the following command:

ffmpeg -f avfoundation -list_devices true -i ""

FFmpeg will output an error stating that the input name is empty, but just above that error, it will print a list of detected video and audio devices.

Look under the AVFoundation audio devices section for your interface. The output will look similar to this:

[AVFoundation indev @ 0x7f8460405800] AVFoundation audio devices:
[AVFoundation indev @ 0x7f8460405800] [0] Built-in Microphone
[AVFoundation indev @ 0x7f8460405800] [1] Focusrite Scarlett 2i2

Note the index number in brackets next to your audio interface (for example, 1).

2. Capture Audio Using the Device Index

To capture audio without video, format the input parameter -i as ":<audio_device_index>". The colon tells FFmpeg that you are omitting a video source and targeting an audio source.

Run this command, replacing 1 with your interface's index number:

ffmpeg -f avfoundation -i ":1" output.wav

Press Ctrl + C to stop the recording.

3. Capture Audio by Device Name

You can also specify the interface using its exact name instead of an index. This prevents issues if device indices change after a reboot:

ffmpeg -f avfoundation -i ":Focusrite Scarlett 2i2" output.wav

4. Configure Channels, Sample Rate, and Codecs

Audio interfaces often support high sample rates and multiple input channels. You can explicitly set parameters such as the sample rate, channel count, and audio codec.

To record a stereo stream at 48kHz to an uncompressed 24-bit WAV file:

ffmpeg -f avfoundation -ar 48000 -ac 2 -i ":1" -c:a pcm_s24le output.wav

To record directly to an AAC-encoded M4A file at a specific bitrate:

ffmpeg -f avfoundation -i ":1" -c:a aac -b:a 192k output.m4a