0

Is there a way I get PHP (or anything that runs on a linux webserver) to record a (radiostation's)audiostream? Yes, I have sought a lot, but I can't seem to find anything like it, though I'm convinced I can't be the first one - right?

My goal is to record an audiostream and then chopping parts of it when listeners are on, so they can listen to themselves afterwards (and family, friends and so on).

So recording, uploading, chopping and publishing would be nicer as I have some volunteers willing to do the chopping part (that I think I can take care of). Maybe there is a service I haven't found (yet)?

Thnx for any relpy.

Bas van Ommen
  • 1,243
  • 2
  • 12
  • 20

1 Answers1

3

I've found it now on this site: http://www.freelists.org/post/darkice/Using-cron-and-wget-for-hourly-archiving-Was-Ogg-Recording-and-Cutting,1

Just in case:

The following bash shell is launched on the hour by cron:

#!/bin/bash
#Go to the archive directory:
cd /aa/icecast/archive
#Stop the archiving for the last hour:
kill `cat archivePID`

#Start recording in the background (&) a new archive file of the stream "http://127.0.0.1:8000/stream.ogg":
wget http://127.0.0.1:8000/stream.ogg &

#Get the Process IS for the job we just started:
echo $! > archivePID

#Wait a few seconds to make sure the job has started and the archive file has been opened:
sleep 5

#Rename the current archive file to a name based on the date and time (YYYYMMDD-HHMM.ogg):
mv stream.ogg `date +%Y%m%d-%H%M.ogg`

This runs on our icecast box and picks up the stream from icecast via the local IP 127.0.0.1, but it could run from any Internet-connected box (by changing 127.0.0.1:8000 to the url of the stream).

Wget opens an output file with the same name as the input stream ("stream.ogg" in our case). But a few seconds later, the script renames the file to a name based on the current date and time. (Wget is oblivious to this since it is writing to an open file handle rather than the file name.)

Note that our stream is in ogg format and is named "stream.ogg", and the shell script reflects that. If your stream is in mp3, or is named anything other than stream.ogg, you'll need to change the script accordingly (specifically the wget command and the mv command).

Hope that helps.

Regards,

John

I've tested it with recording an AAC (ASX stream sent AAC-data? - not familiar with how this stuff works or defined) and a MP3 stream. Both recorded fine and VLC had no problem with playing it. However, the ASX-file seems to be too damaged (logically, as it is a stream which you get a party of) for playback by known webplayers (e.g. JWPlayer / Longtail). But the recorded parts of the MP3 stream don't seem to be affected by that.

Downside on the use of MP3's vs AAC == 45Mb vs 12Mb (per hour @96kbps - I guess).

Hope to help someone with putting Johns work out here.

Bas van Ommen
  • 1,243
  • 2
  • 12
  • 20