I'm looking for a command line program to capture audio from a microphone, save and stream it over a WAN.

arecord test.wav seems to work for recording input, but I cannot figure out how to get it to save as an mp3 for file size reduction.

could I stream audio over SSH? would VLC work?


If you'd rather not get too heavy about this, you can just stream over the raw sound, like you suggest in your question. You can also convert it to MP3 (or another codec - speex might be worth it, if it can be streamed) to save a bit of bandwidth.

Here's what I'm running successfully here:

ssh oli@bessy "arecord -q -t raw | lame -x -r -" | mpg321

That just uses arecord to record from the default source (-q is there to keep it quiet). That can, of course, be tuned. That recording data gets piped through lame which is an MP3 encoder. That output is received back over SSH to your client machine, where it gets piped into mpg123, a command line MP3 player.

Note I have SSH key authentication set up, so there's no password prompt. I'd suggest you do something similar.

You might have issues with arecord. I tried it on our media centre first of all but that wasn't having any of it. I stopped trying to guess which device it wanted me to use and tried the laptop which "just worked".

| improve this answer | |
  • 1
    ... |mpg321 - didn't read its stdin well for me. Sound was sporadic (mostly off, choppy) apparently waiting for next chunk of mp3 data from lame, but arecord doesn't buffer longer than 500ms, which is not a lot of data for hiss. This simplified version gave me steadier sound: ssh user@micserv arecord |aplay – Marcos May 30 '12 at 20:37
  • 1
    Or if you prefer to run on the remote host that has the microphone: arecord |ssh user@speakerserv aplay – Marcos May 30 '12 at 20:40

I'm not entirely sure what your end game is (intercom, just broadcast, etc) but there are a number of options based on existing tech:

  • Group chat options like TeamSpeak are good for multiple applications where you want a talk-on-demand feature but require a client-server structure. It's all free and it's probably the best set up for a very-low-bandwidth situation.

  • Radio streams like IceCast (see here for help on setting it up) are good when you're got a little more bandwidth to play with. It still uses an intermediary server to stream the audio out to clients but this can be installed on your local computer.

| improve this answer | |
  • this would run on a server without a gui and used to hear/monitor whats going on in the server room. – waspinator Feb 7 '12 at 19:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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