4

I would like to record the output audio of my Mac to an audio file using the command line, where I can specify the length of time to record.

So for example, I might ask the command to record to a file for 10 seconds. How do I do this? Can it be done using SoX? I’m open to other methods including the use of an API.

0

1 Answer 1

1

You can use Soundflower to direct the output audio to SoX.

Install Soundflower, then go to “System Preferences > Sound”, and set Soundflower (2ch) as both the output device and input device. Then record 10 seconds using SoX, e.g. as suggested in this question and answer thread.

To switch to Soundflower as output/input device (and back) you can use the switchaudio-osx tool, which you can install via Homebrew.

Use the commands:

SwitchAudioSource -s 'Soundflower (2ch)' -t 'output'
SwitchAudioSource -s 'Soundflower (2ch)' -t 'input'

Using Soundflower, SoX, and switchaudio-osx together, it should be possible to write a script to do the whole process, with an argument for specifying the length of the recording.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .