How to convert .ogg to .mp3?

15

4

Ubuntu ripped a CD for me into audio files but they are all .ogg format which I can't play on my MP3 player.

How can I convert .ogg files to .mp3 files?

Edward Tanguay

Posted 2009-07-29T22:58:45.423

Reputation: 11 955

8Keep in mind that by doing this conversion you're going to lose some sound quality. – Sasha Chedygov – 2009-07-29T23:19:30.653

Please see here for my script: https://askubuntu.com/questions/442997/how-can-i-convert-audio-from-ogg-to-mp3/1064524#1064524

– woohoo – 2018-08-11T21:47:12.373

3Yes, it's better to re-rip the CD directly to MP3s. – endolith – 2009-11-16T02:18:56.307

3@musicfreak which you wouldn't really hear. Seriously this madness needs to stop. Most, if not all, humans cann't distiguish between 320kbit quality and 128kbit quality. There have been recent studies which prove that for a fact. – Grumpy ol' Bear – 2009-11-20T09:13:35.343

@NoCanDo yeah yeah, sell your logic elsewhere. I like 320kbit 'cause the number's bigger. ;) – mrduclaw – 2009-12-08T18:01:34.243

Answers

11

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 ;).

jtimberman

Posted 2009-07-29T22:58:45.423

Reputation: 20 109

@jtimberman: Cant vouch for the quality of this app, but you certainly hit the nail on the head :) – Nippysaurus – 2009-07-29T23:28:14.253

I recall using it a couple years ago when I ran into a similar issue, though I think I compiled from source. – jtimberman – 2009-07-29T23:53:16.293

19

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.

evilsoup

Posted 2009-07-29T22:58:45.423

Reputation: 10 085

avconv did not preserve id3v2 tags – woohoo – 2018-08-11T21:46:36.757

Please see here for a little script that converts ogg to mp3 and preserves tags: https://askubuntu.com/questions/442997/how-can-i-convert-audio-from-ogg-to-mp3/1064524#1064524

– woohoo – 2018-08-11T21:52:19.503

5minor note: would prefer ${f/.ogg/.mp3} over ${f/ogg/mp3} because the latter translates e.g. Goggle.ogg to Gmp3le.mp3. – user829755 – 2014-03-23T13:35:30.423

8

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.

rob

Posted 2009-07-29T22:58:45.423

Reputation: 575

3if you get this error: "sox FAIL formats: no handler for file extension `mp3'". This helps: sudo apt-get install libsox-fmt-mp3 – guettli – 2014-08-29T15:28:23.263

7

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.

staticsan

Posted 2009-07-29T22:58:45.423

Reputation: 726

This is about the first package I install any time I do a clean install of Ubuntu. a must have! – codeLes – 2009-07-30T15:33:52.153

3

You'll find the application Sound Converter in the menu under Sounds & Video Very easy to use GUI, does the job. To install Sound Converter search for it in the Ubuntu Software Center or open the terminal and run the command:

sudo apt-get install soundconverter

Paul

Posted 2009-07-29T22:58:45.423

Reputation: 131

2

If you're looking for an easy to use application, try soundconverter for GNOME or soundkonverter for KDE (both available from the repositories). If you prefer CLI applications, you can't do much better than Perl Audio Converter. There's a Debian/Ubuntu package on the Downloads page there.

Of course, the best answer is to re-rip from the CD to avoid loss of quality. By converting from one lossy format to another, it's like making a photocopy of a photocopy. Quality suffers.

Ryan C. Thompson

Posted 2009-07-29T22:58:45.423

Reputation: 10 085

1

CDex. The best Windows-based ripping and conversion tool ever. Open source. It's been a while since I used it last, it's not intuitive but once you figure it out it's very powerful.

shufler

Posted 2009-07-29T22:58:45.423

Reputation: 1 716

3"Ubuntu ripped.." - indicates he's using Ubuntu, not Windows. – jtimberman – 2009-07-29T23:33:22.950

1+1, even though it may not help the original question, it cannot hurt to have an answer for Windows available too. – jerryjvl – 2009-07-30T02:32:24.067

My bad. Maybe it makes sense to make this question "How do you convert .ogg to .mp3?" and then have multiple solutions or solutions for different platforms. – shufler – 2009-07-30T19:22:09.940

0

fre:ac is the best audio converter that I have found. Fast, free, open-source, multiple platforms (Windows, OS X, Linux, BSD, etc.) and an easy-to-use UI.
Supports many file formats, including .ogg and .mp3 (LAME encoder download seperate)

Nate Koppenhaver

Posted 2009-07-29T22:58:45.423

Reputation: 3 523

0

GPodder will convert .OGG to .MP3 directly unless you tell it your device supports Ogg containers. Look in the repostitories, it's there.

You can learn WHY Ubuntu ripped your CD to Vorbis here.

Broam

Posted 2009-07-29T22:58:45.423

Reputation: 3 831