I enjoy listening to audio lectures on my MP3 player while driving or walking. However, many of these lectures are encoded as Real Audio, and could not be easily converted. I searched for a native OS X app that could perform this task, but found nothing. In the Windows world, programs like Streambox Ripper can convert Real Audio to other formats, but running VPC is not an option for me -- not to mention it's incredibly slow. By using a few freely available UNIX command line tools, and codecs from the OS X version of Real Player, one can easily and quickly convert Real Audio to MP3. What follows is a tutorial, including a shell script to automate the conversion process.
Prerequisites:
Before beginning, you will probably want to have some basic understanding of the command line, namely, how to copy files, use sudo, and set paths. You will also need to have LAME installed, and it should be in your path. This tutorial will not go into basic shell usage.
This hint builds off of this older hint, by correcting some mistakes, and attempting to automate the process a bit. You will need to obtain the newest mplayer and mencoder binaries from the mplayerosx page; the latest version is preferred. Secondly, if you do not have it already, you will need to download the free version of Real Player. Alternatively, if you do not want to download Real Player, the necessary codecs for this project can be obtained from the Helix DNA Producer program. If you choose to go this route, obtain the latest stable OS X releases.
Putting Everything Together:
After obtaining the necessary items, you will want to move the mencoder and mplayer binaries to a location in your path; /usr/local/bin is probably the best candidate. However, you may need to manually add it to your path, and also create the directory. To do this, use pico (or your favorite text editor) to create a file called .profile and place it in your home directory. It should contain the following line:
export PATH=$PATH:/usr/local/bin
After doing this, you will want to also ensure that LAME is in your path. If typing lame while in your home directory does not start LAME, then it is not in your path.
ln -s /Applications/RealPlayer.app/Contents/Frameworks/HXClientKit.framework/HelixPlugins/Codecs \
/Library/Application\ Support/ffmpegX/reallib
If you decided to use the codecs from Helix DNA Producer, create a folder under /Library/Application Support/ffmpegX labeled reallib, and copy the contents of the 'codecs' folder to that directory.
#! /bin/bash
#
# Converts a Real Audio file to a mono MP3 and adds an ID3 tag.
#
# Usage: ra2mp3 infile [outfile]
#
author=`mplayer "$1" -vo null -ss 10:00:00 | grep author | sed -e 's/.*:\\s*\\(.*\\)/\\1/'`
title=`mplayer "$1" -vo null -ss 10:00:00 | grep name | sed -e 's/.*:\\s*\\(.*\\)/\\1/'`
mplayer "$1" -ao pcm -aofile "$1".wav -vc dummy -vo null
lame -m m "$1".wav "$2" --tt "$title" --ta "$author"
rm "$1".wav
To use this script, you will need to copy it to somewhere in your path; again, /usr/local/bin is a good choice. It can then be evoked from any directory. Also, you will need to set the script to be executable; to do this, type:
chmod +x ra2mp3
The script is evoked with the following syntax:
ra2mp3 input.rm output.mp3
It will first run the input file through mplayer to determine its author and title. Then, using mplayer again, it will convert the file to a WAV, and take the author and title info to create an MP3 with matching ID3 tags. The WAV file used during the conversion process will be deleted automatically. Also, you may notice that LAME is being called with the flag -m m. Since I deal mostly with audio lectures, I convert the audio to mono; if you do not wish to do this, simply remove the flag from the script. Additionally, by typing lame at the command line, you can find a number of parameters that may be of personal use, and could subsequently be added to this script. Unfortunately, I know nothing of GUI programming, so if someone would like to make this process even easier, feel free :).
Mac OS X Hints
http://hints.macworld.com/article.php?story=20050130184054216