How to record audio from terminal in macOS Mojave

audioterminal

Since macOS Mojave apps now need to ask for permission to record audio. I want to record it from the built-in microphone of my Macbook.

This means that a lot of old tools are broken. For example, sox and ffmpeg don't work anymore.

With ffmpeg I tried ffmpeg -f avfoundation -i ":1" -t 10 output.mp3, which results in no file being even created.

With sox I tried sox -d output.wav, which produces a file but with no sound in it.

So does anyone have a workaround or other CLI utility that can do this?

Best Answer

They have restricted access to the microphone from the terminal by default after the update.

You need to go to System Preferences > Security & Privacy > Privacy > Microphone and tick the box for the terminal and it should all work again.