Friday, August 13, 2010

Still adding to the server... Using Mimms to Record MMS Audio Streams in Ubuntu Lucid 10.04

I like to listen to a couple radio shows that stream on the internet, so I am putting all that unused power in my little'ol server to use. I tried to use Mplayer and VLC to record streams, but they seemed too sensitive to connection issues for my taste, so I decided on something made just for the purpose. Mimms. After recording and converting the file to mp3, I save it to a couple of places, like my Dropbox... Now I don't have to remember to sync the player before work.

Mimms is in the repos, but it needs python 2.5 and that isn't, so you need to drop to the command line and do the following
  • sudo nano /etc/apt/sources.list
  • add the following to the end of the file
deb lucid main
deb-src lucid main
  • press O to save (thats the letter)
  • press X to exit
  • Now get the packages with the following
sudo apt-get mimms python25

Now here is an example of my script I use to record a radio show:

#record an audio mms stream and convert it to mp3
#then copy them to a network share, then move them to my Dropbox
#Scott Goodgame 2010
TIMESTAMP=$(date +”%b-%d-%y”)

#(use mimms to record the show for 243 minutes)
mimms -t 243 "mms://AStreamNameGoesHere" /home/jack/radio-to-radio-$TIMESTAMP

#convert asf to wav and then from wav to mp3 (if anybody has a better way to do this, let me know!)
mplayer /home/jack/radio-to-radio-$TIMESTAMP -ao pcm:file=/home/jack/radio-to-radio-$TIMESTAMP.wav
lame /home/jack/radio-to-radio-$TIMESTAMP.wav /home/jack/radio-to-radio-$TIMESTAMP.mp3
#copy the file to the network share, move it to a daily directory and move it to my dropbox, then clean up the mess
cp radio-to-radio-$TIMESTAMP.mp3 /home/jack/Dropbox
cp radio-to-radio-$TIMESTAMP.mp3 /media/other/Audio/Today
mv radio-to-radio-$TIMESTAMP.mp3 /media/other/Audio/Podcasts/radio

rm /home/jack/radio-to-radio-$TIMESTAMP
rm /home/jack/radio-to-radio-$TIMESTAMP.wav

Now, just paste that into a file, put a stream in the mimms line and edit the time on the same line.

My particular show plays every night, so I made it a cron job to run every night- here is the relevant line from my crontab:

# m h dom mon dow command
57 00 * * * /home/jack/bin/record-raido-show

My show starts at 1am, but I start the job early because sometimes it takes a few seconds for mimms to connect and I don't like to miss anything.

I was going to tell you about editing the crontab file, but why reinvent the wheel? Here is a really nice link to get you started....

Happy recording!


No comments: