Record radio / audio stream (asx/asf) with a webserver

自古美人都是妖i 提交于 2019-12-04 21:31:37

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.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!