Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

A command line ogg to mp3 converter UNIX
Using the same paradigm as ChrisR's flac to mp3 command line script, I've done the same to convert ogg files to mp3s using command line tools.

You'll need to download and compile the vorbis player/encoder tools for everyone from vorbis.com. Its kind of tricky; you'll need to install libao2, libogg and libvorbis libraries using fink, then compile with the following:
./configure --with-ogg=/sw --with-ao=/sw --without-flac
I didn't bother to compile with flac support, because I use flac to do that. You might get some errors during the configuration, and they are pretty good about what's causing the problem. If you're missing any libraries, check to see if fink has (or can) install them. You'll also need to install LAME with fink. It was simple.

Finally, here's the shell script that you can run in a directory full of .ogg files when you're ready for bed. Feel free to change any of the options in the lame converter, and see ChrisR's post for information about IDv3 tags with command line tools if you're interested.
#! /bin/sh
# Andy Freed - 2004
# this uses fink installed flac to convert
# .ogg vorbis audio to .mp3 files with 
# the fink installed LAME encoder.
# modified from flac script by ChrisR on MacOSXHints.com
for file in *.ogg
do
  ogg123 -d raw -f - "$file" |
  lame -h -m s -b 192 - "$(basename "$file" .ogg).mp3"
done
[robg adds: I haven't tested this one ... and remember to make the script executable (chmod 755 script_name).]
    •    
  • Currently 2.20 / 5
  You rated: 2 / 5 (5 votes cast)
 
[67,242 views]  

A command line ogg to mp3 converter | 15 comments | Create New Account
Click here to return to the 'A command line ogg to mp3 converter' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
fink already has the vorbis-tools
Authored by: The Tired Saint on Aug 09, '04 05:16:28PM

You don't need to download and compile anything yourself! Fink already has the vorbis-tools package (which includes ogg123), although it is in the unstable tree. To access it, just add "unstable/main" to the Trees: line in your /sw/etc/fink.conf file. (While you're at it, "unstable/crypto" might not be a bad idea.) Then do a selfupdate, and the vorbis-tools package will become available.



[ Reply to This | # ]
Pointless?
Authored by: react on Aug 09, '04 08:32:39PM

I really don't see the point in this script?

You're converting from a lossy format to another lossy format.....so you'll end up with a worse quality mp3 in the end than if you just stuck with the ogg vorbis file.

The only I can see for doing this is converting a ogg to mp3 to play on your iPod, but then it would be better if you just went and download a mp3 in the first place. Plus if you share your converted mp3 you're just going to be contaminating p2p with a crappy quality version.



[ Reply to This | # ]
Pointless? I don't think so...
Authored by: dontlikehippies on Aug 09, '04 09:54:21PM

i used this script because iTunes hiccups when reading .ogg files. before this, if i wanted to convert .ogg to .mp3, i was forced to use AudioHijack Pro (and play each song all the way through). thanks!



[ Reply to This | # ]
Pointless? I still think so...
Authored by: react on Aug 09, '04 10:59:15PM

Yeh, well that pretty much fits into my iPod reasoning, but as I said for that you would be better off grabbing a mp3 encoded from the original cd.

Converting from one lossy codec to another is not the way to go.



[ Reply to This | # ]
Pointless? I don't think so...
Authored by: miggins on Aug 09, '04 11:54:16PM

Have you tried using the faster version? Get the latest from here: http://qtcomponents.sourceforge.net/



[ Reply to This | # ]
Pointless?
Authored by: mrgerbek on Aug 09, '04 11:36:45PM

I agree that its not ideal, but even you point out a reason for it in your explanation of why its pointless ;)

I was looking for a way to do it, noticed that someone else had also asked how to do it, then decided to submit it as a hint instead of a reply. Except for a few malformed bits, no harm done.

Andy

---
~~~~~~~~~~
Be Green



[ Reply to This | # ]
Pointless?
Authored by: /mecki78 on Aug 10, '04 07:05:37AM

It's not pointless at all! I make all my CDs to OGG and I buy music *legally* online in OGG format, too! Why? It sounds better and needs less space! Why should I use crappy MP3 for that?

But mobile players (unless the very expensive ones) don't play OGG. So to play them out of house, I must covert them to MP3. But this is just for the mobile player. At home I keep using the OGGs.

For a mobile player, MP3 with 128 kbit/s may even be enough, they won't sound much worse through crappy headphones and with all the street noise around me. But at home I want High Fidelity! 192 kbit/s MP3 are hardly enough, while OGG Level 5-6 (170-200 kbit/s) are usually transparent for me, even on good sound equipment.

I don't "share" the "bad" MP3s or anything, they are for my private use on mobile players or wherever I can't use OGG out of some other reason. Wherever I can, I only use OGG.

The MP3s are just cheap copies (I don't even keep them! I usually create them when I want them on my player and delete them if I replace them --- I have no IPOD and may player has only 256 MB storage for MP3s).

And trust me, I bet $1000 that you won't be able to tell the difference between

CD -> MP3 192 kbit/s
CD -> Ogg q6 -> MP3 192 kbit/s

No way!

I know losy to losy is bad, but some pictures where also stored as JPG multiple times and you still can barely see any artifacts. Same with audio. You can re-compress a MP3 to MP3 three to four times without having crap as result (of course only if the bitrate is high enough; 128 to 128 is already very bad). And OGG takes much "less" away of the music than MP3 does and since OGG adds different kind of artifacts than MP3, they don't sum up as in MP3 to MP3 re-encoding.

However, I would always choose LAME VBR (e.g. lame --preset standard) for re-encoding, as it preserves most quality.



[ Reply to This | # ]
Pointless?
Authored by: midtoad on Jul 11, '05 08:17:04PM

the point might be that iTunes is very slow in adding .ogg files to its library, and it skips a lot when playing .ogg files if you are doing anything else at the same time (at least for my case, with the .ogg files on a remote PC on my home network; YMMV).

As for transcoding crapping out the quality, that's certainly the accepted view. But at least one individual's report suggests that he couldn't tell the difference, even with a double-blind test.



[ Reply to This | # ]
a plugin to play oggs in iTunes
Authored by: alys on Aug 09, '04 11:19:08PM
This hint tells you how to install a plugin that allows iTunes to play ogg files. If you're thinking of converting oggs to mp3s solely so that you can play them in iTunes, then using the plugin is a much better option. Ogg files will be smaller for the same quality (or better quality for the same size) than mp3 files.

[ Reply to This | # ]
a plugin to play oggs in iTunes
Authored by: midtoad on Jul 11, '05 08:13:30PM

Sure, ogg files are smaller than mp3 files. But iTunes is *very* slow to add .ogg files into its library. Trust me, I just imported 26000 songs, of which half were .oggs. It took at least 8 hours, IIRC (with my library on a USB drive connected to a Windows PC on the home network).

It would probably be faster to convert my entire collection to .mp3 and then add those to the library!



[ Reply to This | # ]
A command line ogg to mp3 converter
Authored by: midtoad on Jul 18, '05 02:22:19AM

Would it be possible to modify the flac-to-mp3 script so that after the ogg files are converted to mp3, the ogg comments are converted to mp3 ID3 tags, and finally the original ogg file is deleted?

Has anyone done that, and would like to share their script?

thanks
S


---
Calgary, Alberta
Mac Mini



[ Reply to This | # ]
A command line ogg to mp3 converter
Authored by: daveola on Feb 13, '06 08:21:40PM
There's a command line script (written in perl, which OSX comes with) that does exactly this at MarginalHacks.com:

http://marginalhacks.com/#ogg2mp3

---
http://GetDave.com/
http://MarginalHacks.com/

[ Reply to This | # ]

A command line ogg to mp3 converter
Authored by: daveola on Feb 13, '06 08:23:50PM
There's a command line script (written in perl, which OSX comes with) that does exactly this (including copying tags) at MarginalHacks.com:

http://marginalhacks.com/#ogg2mp3

---
http://GetDave.com/
http://MarginalHacks.com/

[ Reply to This | # ]

A command line ogg to mp3 converter
Authored by: reformist on Jan 27, '07 01:30:09AM

I just realized this, but ID3 has the limitation of only allowing 30 characters per field. I have tons of song titles over that length, and the marginalhacks script (or any script for that matter) truncates the title.

Unacceptable!

I'm trying to convert away from ogg to mp3 or some popular format, because ogg is not well supported by hardware or itunes.



[ Reply to This | # ]
A command line ogg to mp3 converter
Authored by: blentz on Feb 15, '10 07:27:11PM

I had filenames with spaces and I wanted to process a directory tree recursively, so I ended up doing something like this (note that I'm using "-d wav" not "-d raw")

$ find Desktop/Music/ -type f -name "*.ogg" -exec echo ogg123 -d wav -f - \"{}\" \| lame -h -m s -b 192 - \"{}.mp3\" \; | bash

The ogg123 and lame tools and associated libraries were available in fink.

$ fink install libao2 libogg libvorbis vorbis-tools lame



[ Reply to This | # ]