Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have audio being feed to the line in jack for my iMic USB Audio device. I have LAME & Vorbis OGG Tools installed using MacPorts. How do I directly record the line in jack using command line software? I know in Linux there is the program arecord, but what do I use in Mac OS X 10.6 to accomplish this? Is there a way with LAME or OGGENC using raw options?

I'm trying to put together a BASH script to record then forward the audio file and I just need to know how to grab the line in audio to save to a file so I can use another program to auto forward it.

share|improve this question

The problem turns out to be alot harder than it should be.

Normally I would recommend SOX, but I ran into an issue getting it to record audio:

It's pretty easy to come up with a simple python script, but due to a bug in the wave module it can't be used in a pipe:

Ecasound is another common program I have used on Linux/FreeBSD, but it doesn't support coreaudio on OSX and can't be used for recording.

At the end of the day the best I have found is a 2 stage process where I record the audio with one script and then convert to mp3 with lame.

Here's a simple python script. Adjust the INDEX to be the appropriate device index from the system preferences list:

    #!/usr/bin/env python2.5

    import sys
    import pyaudio
    import wave

    FILENAME = 'recording.wav'
    INDEX = 0
    FORMAT = pyaudio.paInt16
    CHANNELS = 2
    RATE = 48000
    CHUNK = 1024

    p = pyaudio.PyAudio()
    stream =
        format = FORMAT,
        channels = CHANNELS,
        rate = RATE,
        input = True,
        frames_per_buffer = CHUNK,
        input_device_index = INDEX)

    wf =, 'wb')

    while True:
            # sys.stdout.flush()
        except IOError:

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.