FFmpeg: How to Capture Audio With Mic

Updated

Capture audio directly from your microphone using FFmpeg on macOS

FFmpeg: How to Capture Audio With Mic

Before we get started, make sure you have FFmpeg installed on your computer and open up your Terminal application.

1. Find Microphone Device Index

First, we need to locate the device index for your microphone. Run this command in your terminal:

ffmpeg -f avfoundation -list_devices true -i ""

Look through the terminal output under the AVFoundation audio devices list to find your microphone and note its corresponding number, which is often 0. You might see an error message at the bottom of the output, but you can safely ignore it because that is expected when listing devices.

2. Record the Audio

Next, you can start recording audio from your microphone. Enter this command, replacing :0 with your microphone's index number if yours was different:

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

FFmpeg will begin recording right away and save the audio to output.wav. Speak into your microphone for a few seconds, then press q or ctrl + c on your keyboard to stop recording.

To quickly test that your audio recorded properly, play the file back by running afplay output.wav in your terminal or double-clicking the file in Finder.