Solution 1:

There's several ways you can do this. Probably the easiest is to use a tool called ogg2mp3. Details on the Ubuntu forums about how do install it:

$ sudo apt-get install mp32ogg lame
$ wget ftp://ftp.pbone.net/mirror/plf.zarb.org/plf/mandrake/10.1/noarch/ogg2mp3-0.3-3plf.noarch.rpm
$ sudo alien ogg2mp3-0.3-3plf.noarch.rpm
$ sudo dpkg -i ogg2mp3_0.3-4_all.deb

While this is an RPM for Mandrake, it should work fine after running it through alien and installing the .deb. And in the future, you can use lame to rip CDs in mp3 format as it's installed in the first step.

As is commonly pointed out, converting from one lossy format (ogg) to another (mp3) will degrade the quality of the music. But its better than not being able to play the music on your portable device at all ;).

Solution 2:

Transcoding from one lossy format (vorbis) to another (MP3) is not ideal, but unfortunately it is necessary sometimes, especially if one has an ageing audio device. The command-line tool avconv can do this well (ffmpeg uses identical syntax).

avconv -i input.ogg -c:a libmp3lame -q:a 2 output.mp3

will give you a variable bit rate MP3: this means that the encoder will alter the bit rate depending on the needs of the music. Dubstep needs a higher bit rate than whalesong. On average, over several pieces of music, -q:a 2 will get you 190 kbit/s, though most of them will be over or under that bitrate.

The quality setting -q:a ranges from 0 to 9, where 0 is best quality and 9 is worst. Here is a more in-depth guide. For most people, -q:a 2 is more than good enough.

To convert a directory full of oggs vorbis to MP3 (on the Linux or OSX command-line), use

for f in *.ogg; do avconv -i "$f" -c:a libmp3lame -q:a 2 "${f/ogg/mp3}"; done

Sometimes people need to use a constant bit rate, for some really obsolete hardware, or for streaming. If that is the case,

avconv -i input.ogg -c:a libmp3lame -b:a 192k output.mp3

This would be of broadly the same quality as -q:a 2, though the VBR mode should generally be preferred.

If you want a GUI frontend, WinFF might be worth looking at.

Solution 3:

SoX is the Swiss Army Knife of sound processing utilities http://sox.sourceforge.net/

for f in *.ogg; do sox "$f" "${f%.ogg}.mp3"; done

its like vlc for audio files. It is so old it was ported to the Amiga in 1994.

Solution 4:

If you install the package ubuntu-restricted-extra then you can rip to MP3 instead of Ogg Vorbis. Ubuntu doesn't ship with the MP3 encoder by default because of the legal minefield about who owns it.