Tuesday, June 20, 2006

Roll Your Own MP3

If you are as old as me you can remember setting up your boom box to record your favorite radio station or show to tape. I am really going to date myself on this one but I remember taping Dr. Demento and Wierd Al back in the 80's. We were not trying to steal the music. It just happened to be on in the middle of the night. We would tape it and then listen during the day with our friends. Sometimes we would tape our favorite music to take on trips in the car. These were the days of high technology and the Walkman was not too far behind.



Does anyone tape the radio to use with their MP3 player these days. Well yes.... but not from a boom box or other analog device. Today we record digital streams coming from online music stations like the ones you see at Shoutcast. With all of the parinioa surounding DMA and the other crap no one seems to want to give you a piece of software that has a record button. Thats okay. There are a couple of Linux apps that save the day. The first one is mplayer. The second is lame. These two powerful open source apps allow you to record digital music streams and convert them to a useful format (mp3) from the command line. The easy way to get a Fedora Linux box set up to use mplayer and lame is to download these RPM packages and their dependencies from FreshRPMs.net. Once installed the commands look like this.



mplayer -nojoystick -playlist -dumpfile /home/user/audiofile.wav -vo null -ao pcm



lame --preset standard audiodump.wav yourfilename.mp3



Two things I forgot to mention. PLS or playlist files come from the streaming servers. They can be accessed by right clicking on the links to play music when you want to listen to the stream. By copying the link into a pls file you can then reference it in the mplayer command line syntax. Finally the one little quirk that I noticed with lame and the commandline. It only likes encode if I run it as root.



So there you have it. A way to listen to your favorite station when you are away from your computer. Its all legal as long as there are no restrictions on the content like anoying copyrights.