I enjoy listening to music while doing my work, but doing it with online radio is not really enjoyable as during daytime, it’s hard to listen to 128 kbps stream without buffering issue, thanks to TMNut’s Streamyx. Even if (at times) it’s ok, the bandwidth is better saved for other meaningful purposes. What I did was to create a script to dump the broadcast, run it by midnight (the time when the highways is clear for Streamyx) and stop it in the early morning. Let cron help you with this and it should make your life even easier.
In my example, I’m using 1.FM’s Channel X, and a lot more is available from www.shoutcast.com‘s playlists.
(Script updated on 20070301)
#!/bin/bash
URL=http://64.62.252.130:8070
WORKDIR=/home/shakir/temp/mplayerdump
MAXDUMP=3
CURRENTDUMP=`ls $WORKDIR | wc -l`
mv $WORKDIR/current.mp3 $WORKDIR/`date +%F`.mp3
if [ $CURRENTDUMP -ge $MAXDUMP ] ; then
for i in `ls $WORKDIR | head -n $[($CURRENTDUMP-$MAXDUMP)+1]`; do
rm $WORKDIR/$i
done
fi
mplayer -dumpstream $URL -dumpfile $WORKDIR/current.mp3
#ffmpeg -i $URL -ab 128 $WORKDIR/current.mp3
12 Comments on this post
Leave a Commentdis is kewlll…
Comment left on 2.27.2007 by khairul
Thanks, and I’m waiting for someone to comment on the legal issue of doing this
Comment left on 2.27.2007 by shakir
Cool! Mplayer really capable of doing a lots more.
What kind of file format is the dump file been recorded? Can we converted into mp3?
Comment left on 2.27.2007 by mysurface
It’s saved as raw stream, and I haven’t tried any player other than mplayer to play the file. Haven’t tried converting it too, but I guess mencoder can help with that.
Comment left on 2.28.2007 by shakir
Haha, just put as .mp3 will do, I have tried.
mplayer -dumpstream $URL -dumpfile $DUMPDIR/current.mp3
by the way, you can use ffmpeg for dumping too, and it is much more better, because the size of the file is visible to you.
ffmpeg -i $URL -ab 128 current.mp3
Comment left on 2.28.2007 by mysurface
Thanks for pointing these out. And talking about size, the original script should be updated to delete old dumps as one night’s dump can take around 300MB for a 96kbps stream.
#!/bin/bash
URL=http://64.62.252.130:8070
WORKDIR=/home/shakir/temp/mplayerdump
MAXDUMP=3
CURRENTDUMP=`ls $WORKDIR | wc -l`
mv $WORKDIR/current.mp3 $WORKDIR/`date +%F`.mp3
if [ $CURRENTDUMP -ge $MAXDUMP ]
then
for i in `ls $WORKDIR | head -n $[($CURRENTDUMP-$MAXDUMP)+1]`
do
rm $WORKDIR/$i
done
fi
#mplayer -dumpstream $URL -dumpfile $WORKDIR/current.mp3
ffmpeg -i $URL -ab 128 $WORKDIR/current.mp3
Comment left on 3.1.2007 by shakir
how about if you want to just record one show from say 10:00 am to 12:00 pm for 2 hours? Can you help with that please..
thanks,
vishal
Comment left on 7.25.2007 by Vishal
Hi, I dunno if you could use this, but I have modified an bash script which I found on the Internet myself. Its called radio_rip. I modified it best for my needs, and it saves bandwith because you can hear and record music just with one single connection to the streaming server. because of the base how its working, it has some buffer seconds, which perhaps could be enough for your internet connection too. I would advise that you try it, and perhaps you could mail me how you found it. See http://www.donneker.de/projects/radio-rip
hf & gl
Comment left on 7.26.2007 by Donneker
Vishal: You can take a look at cron and see what you can do to start the script. As to stop it, I normally have a killall command in my cron entry, or to be based on the mplayer’s man page, you’re supposed to be able to do this too:
-endpos 56
Stop at 56 seconds.
-endpos 01:10:00
Stop at 1 hour 10 minutes.
Donneker:
I’ve downloaded and tried you script + streamtuner, and I must say it’s a good one. My script however is meant for a simple purpose and I hope it serve its purpose well
Comment left on 7.26.2007 by shakir
For legalties, it’s not a problem. RIAA even confirmed it.
http://hypebot.typepad.com/hypebot/2007/07/riaa-admits-str.html
Comment left on 7.27.2007 by KwangErn Liew
this script Stop the record.
only required adjust the recording time via the crontab
#!/bin/sh
aa=`ps -A | grep mplayer | awk ‘{print $1}’`
kill -9 $aa
Comment left on 8.5.2008 by A
i have a Stream and I want to create 1 minute capsules of the stream continuously,, how can i do it with ffmpeg or any other tool ?
Comment left on 12.17.2009 by Daljeet