I've often wanted to convert the audio tracks from my DVDs into an MP3 or even OGG. This allows me to make the audio more transportable. Then you can take the sound files to work, put them on your portable MP3 player, or even your car MP3 player. This is great for those obscure director commentaries you don't have time to watch.
To convert DVD audio to an MP3 or OGG you will need the following:
Once you've picked out the DVD you want to convert we'll need to figure out how many audio tracks it has. MPlayer can tell you this if you run it in verbose mode. Simply start MPlayer like so:
mplayer -v dvd://
and looking at the output. Look for the audio stream lines. They should say:
==> Found audio stream: XXX
There may be several of those lines. Each one of those lines corresponds to an audio stream on the DVD. Once you've determined the stream you want to convert we will need to refer to the audio stream number. The audio stream number is the XXX and is referred to as aid in the documentation.
Now we are ready to begin converting the audio track. We'll start by creating a pipe to feed the audio to our encoder, and then we'll actually encode the data next.
lame -b 64 soundpipe audio.mp3 & mplayer -quiet -ao pcm:file=soundpipe -vo null -vc dummy -aid XXX dvd://
The first command creates the pipe that will be used to transfer data between mplayer and your encoder. The second command starts the encoder encoding soundpipe at 64kbs to audio.mp3. MPlayer writes the raw PCM audio to soundpipe. The mplayer command picks the PCM audio codec and a null video codec. You should see status output writing to the screen while it rips the audio. Remember to replace XXX with the aid you want to convert.
Create a 64kbs OGG
oggenc -b 64 soundpipe -o audio.ogg & mplayer -quiet -ao pcm:file=soundpipe -vo null -vc dummy -aid 128 dvd://
Create a 128kbs MP3
lame -b 128 soundpipe audio.mp3 & mplayer -quiet -ao pcm:file=soundpipe -vo null -vc dummy -aid 128 dvd://
Create a 128kbs MP3 of DVD Title 2
lame -b 128 soundpipe audio.mp3 & mplayer -quiet -ao pcm:file=soundpipe -vo null -vc dummy -aid 128 dvd://2
Create a 64kbs OGG of DVD Chapters 1-5
oggenc -b 64 soundpipe -o audio.ogg & mplayer -quiet -ao pcm:file=soundpipe -vo null -vc dummy -aid 128 -chaper 1-5 dvd://