/home/shakir

27 Feb, 2007

Rip / record online radio stream

Posted by: in Information Insemination




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


Bookmark this page:


Subscribe to feed

 

Add to Google Reader or Homepage Subscribe in Bloglines

Powered by FeedBurner

11 Responses to "Rip / record online radio stream"

1 | khairul

February 27th, 2007 at 1:43 am

Avatar

dis is kewlll… :)

2 | shakir

February 27th, 2007 at 1:50 am

Avatar

Thanks, and I’m waiting for someone to comment on the legal issue of doing this :D

3 | mysurface

February 27th, 2007 at 2:00 pm

Avatar

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?

4 | shakir

February 28th, 2007 at 3:58 am

Avatar

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.

5 | mysurface

February 28th, 2007 at 2:32 pm

Avatar

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

6 | shakir

March 1st, 2007 at 12:45 am

Avatar

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

7 | Vishal

July 25th, 2007 at 5:24 pm

Avatar

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

8 | Donneker

July 26th, 2007 at 1:24 am

Avatar

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

9 | shakir

July 26th, 2007 at 2:16 am

Avatar

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 :)

10 | KwangErn Liew

July 27th, 2007 at 8:49 am

Avatar

For legalties, it’s not a problem. RIAA even confirmed it. :)

http://hypebot.typepad.com/hypebot/2007/07/riaa-admits-str.html

11 | A

August 5th, 2008 at 10:07 pm

Avatar

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 Form


  • tebu: nak tanya sikit, untuk maxis punya kenapa dia ada keluar error +CME ERROR: SIM PIN required. user: maxis pass: wap betui ka..sim pin tu nak ke
  • shakir: Ditesh: I'm still able to download the game here from my end, but anyway, I've emailed you the game. p/s: The new Golden Axe game is in the making
  • Ditesh Gathani: Hi, I've been trying to download the said software but the site keeps timing out. Would it be possible for you to share the software through email?
  • apis: he he T Bag....
  • apis: cayalah
  • achoi: Salam, Buku tentang network security xde ke bang. Klu ada nk tempah awl² skit.hee :D
  • shakir: I blog about this actually because I was frustrated when I got no reply from the hosting company after reporting to them about this, though there was
  • Danesh: Talk to the hosting company and get to sponsor you a co-hosted package for your discovery... :D
  • shakir: Thanks for the invite bang. But then, I'm just a (PHP) script kiddie, tak layak nak masuk competition ni.. :)
  • shakir: I've already updated the firmware, and I don't keep copy of it. Sorry.

About


Twitter

Disclaimer

The information in this weblog is provided "AS IS" with no warranties, and confers no rights. This weblog does not represent the thoughts, intentions, plans or strategies of my employer. It is solely my own personal opinion. Inappropriate comments will be deleted at the authors discretion. All code samples (if any, ever) are provided "AS IS" without warranty of any kind, either express or implied, including but not limited to the implied warranties of merchantability and/or fitness for a particular purpose.