Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I'm in the process of setting up an audio processor on my remotely hosted CentOS box. The audio processor itself is command line based, and after speaking with the author he explained to me that it works by reading in a live .WAV stream, and it outputs a live .WAV too.

Now basically, the scenario I have is this:

I have a shoutcast server on this box using port 8000. This shoutcast server is the point at which the DJ's connect.

I have a secondary shoutcast server using port 8002 where the listeners will connect.

In between these, I would like to use this audio processing tool. It would need to connect to the first shoutcast server on port 8000, process the audio, and then send it to the server on port 8002.

The program cannot do this on it's own unfortunately, so I am told by the software author. He also stated that this scenario is workable, providing I use the right method. He suggested something like the following:

  1. Command line tool that reads the incoming stream, and pipes it to:
  2. Command line tool that extracts the MP3 data to WAV format, for example lame with option --decode.
  3. Stereo Tool.
  4. Program that encodes WAV to MP3 data, for example lame.
  5. Program that streams this, which can handle a pipe as input.

Step 1+2 could be replaced by: 'arecord', linked using 'jack' to a program that receives and plays an incoming stream

Similarly, step 5 could be replaced by: 'aplayer', linked using 'jack' to a program that streams audio data.

I do understand what he has said, and I could proably do this if I was using a local install with a GUI and a sound card. But, with me not being majorly familiar with Linux command line, and not having a sound card, I am at a loss as to how something like this could be implemented.

I am totally lost to be honest, and would appreciate some insight from you linux guru's on how to configure something like this. It's mainly the input and output im struggling with.

Thanks in advance for any help.

Dave

share|improve this question
    
if i understand correctly, you get wav input at port 8000 and want to stream mp3 output at port 8002? lame is a program that can handle pipe as input or output arecord | lame -encodingoptionshere - - | aplay –  forcefsck Mar 23 '11 at 19:22
    
Hi. On each port, the data is MP3. I somehow need to connect to that stream and decode "on-the-fly" to a WAV buffer. Then, from a WAV buffer, re-encode to MP3, again, on the fly –  Dave Mar 24 '11 at 9:07
add comment

1 Answer

up vote 1 down vote accepted

I haven't done this before nor tested it nor have thoroughly read the appropriate documentation. And I am not an expert in audio/video codecs and stuff. So this is more of a "this could work" guide and hopefully others can elaborate.

I did a quick search on google, trying to find out some tools that will cover the requirements (only command line tools).

  1. Getting the audio stream from the first server: icecream
  2. Decoding from mp3 to wav: lame
  3. Your Stereo Tool: stereo_tool (hypothetically)
  4. Encoding from wav to mp3: lame
  5. Forwarding audio to the second server: ezstream

Assuming that your shoutcast servers are up and running in the same box. We will make a shell script stream2stream.sh that will read from the first, process and forward to the second.

$ chmod 750 stream2stream.sh
$ cat stream2stream.sh
#!/bin/bash

icecream --stdout http://localhost:8000 | \
lame -decode - - | \
stereo_tool | \
lame --preset cbr 128 -r -s 44.1 --bitwidth 16 - - | \
ezstream -c ~/ezstream.xml

Note that ezstream supports re-encoding by letting you define your own encoding/decoding programs. So my script above may be unnecessary and ezstream may be sufficient by itself. But I'm not familiar with this tool and so in this implementation we have the simplest configuration.

$ cat ~/ezstream.xml
<ezstream>
    <url>http://localhost:8002</url>
    <sourcepassword>hackme</sourcepassword>
    <format>MP3</format>
    <filename>stdin</filename>
    <stream_once>1</stream_once>

    <svrinfoname>My Stream</svrinfoname>
    <svrinfourl>http://yoursiteurl/</svrinfourl>
    <svrinfogenre>YourGenre</svrinfogenre>
    <svrinfodescription>This is a stream description</svrinfodescription>
    <svrinfobitrate>128</svrinfobitrate>
    <svrinfoquality>2.0</svrinfoquality>
    <svrinfochannels>2</svrinfochannels>
    <svrinfosamplerate>44100</svrinfosamplerate>
    <!-- Disallow the server to advertise the stream on a public YP directory: -->
    <svrinfopublic>0</svrinfopublic>
</ezstream>

You will have to adjust the parameters on lame and ezstream to your likings. You can execute the script with nohup or in screen.

screen -AmdS stereotool stream2stream.sh
share|improve this answer
    
Thanks! I'll give this a go tonight :) –  Dave Mar 28 '11 at 10:20
add comment

Your Answer

 
discard

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.