Tuesday, June 14, 2011

Some fun with audio forwarding through ssh

It's pretty simple to forward audio to remote machine using ssh and mplayer. Here is an example how to forward local microphone stream (using ALSA recorder on Linux on local machine with ogg encoder for compression, and mplayer on remote machine):

arecord -f cd -t raw | oggenc - -r | ssh <user>@<remotehost> 'cat - | mplayer -'

If needed change ALSA recorder to any other mic recorder, and just redirect its output to the encoder.

And here is how to forward playing of local audio file to remote machine (cache setting enables mplayer to accumulate the stream, otherwise it fails when too much data comes at once):

cat <audiofile> | ssh <user>@<remotehost> 'cat - | mplayer -cache 8192 -'

Have fun with your audio.

No comments:

Post a Comment