views:

63

answers:

2

Hello. I am attempting to (in NodeJS):

  1. Connect to an Icecast internet audio stream. Ex: http://icecast3.977music.com/comedy
  2. Parse the response headers and extract the icy-metaint value.
  3. Write out the raw audio data to a file, while extracting the metadata bytes from the audio stream in order to:
    • Intercept and parse the metadata when it arrives.
    • Not include the metadata bytes in the output file, so that there are no audio artifacts because of the injected metadata.

Following the "unofficial" Shoutcast Metadata Protocol page from SmackFu, I have been able to get this far:

https://gist.github.com/e7474421dcb25e011620

Basically, I am able to extract the metadata when it is expected (there's only 1 metadata event at the very beginning of the stream dump included in the gist). That part seems to work fine.

The problem is that the output MP3 file has noticeable audio artifacts throughout the file, presumably when the metadata bytes is arriving. However, I am definitely extracting those metadata bytes and NOT including them in the output file, so that's the weird part.

The protocol document in the link above doesn't say anything else needs to be done to the output file, but obviously I'm still doing something wrong. Does anybody know what else needs to be done to the audio stream? Thanks in advance!

A: 

I was able to sort this out on the Node.js IRC channel. I had an "off by 1" error in the amount of audio bytes being output, so and resulted in an invalid audio file.

The gist posted in the OP has been corrected and now WORKS PROPERLY.

A continuation of this little exercise is being packaged into a Node.JS module to read audio and metadata from a SHOUTcast/Icecast stream. Check out node-radio-stream if you're interested.

TooTallNate