Monthly ArchiveFebruary 2007
Code Adam Deacon on 26 Feb 2007
Converting Unix time to Time stamps
I’ve been busy with a lot of time dependant code this week and working in Unix Time (number of seconds since epoch) has been making my brain go a bit squishy. Here a nice little code snippet for converting unixtime to a proper timestamp
perl -e 'print scalar localtime($ARGV[0]),"\n"' [unixtime] so: perl -e 'print scalar localtime($ARGV[0]),"\n"' 1172160024
Thu Feb 22 16:00:24 2007
If you use this a lot, there’s nothing to stop you putting this in a nice little script, such as:
#!/bin/perl
print scalar localtime($ARGV[0]),"\n"
Linux & mplayer Adam Deacon on 01 Feb 2007
Recording RealAudio streams and converting them to MP3
A friend of mine recently had his 5 minutes of fame of Five Live and asked me to if I could covert the “Listen again” to an mp3 so it could be saved for the good of Humanity. Here how I did it:
- Finding the name of the stream can sometime be a bit tricky. If you can get it to play in the stand alone RealPlayer then you can just click on File->Clip properties->Clip source. This will then bizzarely open a webpage. You looking for an address like rtsp://rmv8.bbc.net.uk/radio5/anita_mon.ra. If you can’t open it then it’s a case of looking though the source of the page.
- Now you’ve got the address, run the following command:
mplayer -noframedrop -dumpfile file.rm -dumpstream rtsp://rmv8.bbc.net.uk/radio5/anita_mon.ra
This will save the clip as file.rm. Watch out though, this is recorded in real time. So a 3 hour radio show will take… 3 Hours! - Next you need to covert the realmedia file to wav, again mplayer is your friend
mplayer file.rm -ao pcm:file=file.wav -vc dummy -vo null - Last stage is to convert from wav to mp3 using lame. I like to hedge my bets and encode it as VBR
lame -V file.mp3 file.wav --tt "Title" --ta "author"
You should have have a shiny MP3 file for your troubles.