Rip / record online radio stream
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 to “Rip / record online radio stream”
Post comment
Connect with me
What I'm Doing (via twitter)...
- is applying for US visa. The website is not helping at all http://twitpic.com/16hvxp 5 days ago
- @abumuaaz want to focus on my wireless project (yes, I get paid for that) and some development work. Ada job to pass ka? :) in reply to abumuaaz 6 days ago
- is running 'sudo dd if=/dev/zero of=/dev/sda' on his laptop. Will it work, my computer forensic friends? 1 week ago
- is on his first day of being jobless, hahaha. 1 week ago
- finished reading Crowdsourcing: Why the Power of the Crowd Is Driving the Future of Business, in 32 hours. Next, Wikinomics. 1 week ago
- is on his way to island hopping. Woohoo! 1 week ago
- is leaving on a jetplane, don't know when he'll be back again... 1 week ago
- missed his flight to KK. Will need to take the first flight tomorrow and pray he'll make it for his 9am meeting. 1 week ago
- More updates...
Categories
Tags
bash
blog
book
database
debian
embedded
gutsy
howto
hsdpa
html
kde
kubuntu
linux
lpi
nature
network
Photoblog
photography
php
pylons
python
recovery
script
security
shell
sqlalchemy
ssh
ubuntu
vim
wireless
wordpress












dis is kewlll…
Thanks, and I’m waiting for someone to comment on the legal issue of doing this
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?
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.
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
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
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
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
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
For legalties, it’s not a problem. RIAA even confirmed it.
http://hypebot.typepad.com/hypebot/2007/07/riaa-admits-str.html
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
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 ?