This article is more than ten years old and potentially contains out-dated information.
작성한지 10년 이상 지난 게시물입니다. 최신의 정보와 맞지 않는 내용을 포함할 수도 있습니다.

First of all, you need to install vorbis-tools and lame, assuming you have MacPorts installed. If you’re using some other package management system, that’s fine. Go ahead and install these two packages. If you don’t have any, you can always manually install it.

sudo port install vorbis-tools lame

I’m going to decode an ogg file into a wav file and then convert the wav file to an mp3 file. For example,

oggdec test.ogg
lame -h --vbr-new test.ogg

If you want to make an mp3 file with a constant bit rate, use -b option. Refer lame --help for details. However, it is not a good idea to manually invoke this command for every single file you want to convert. So, I’m gonna make a very simple shell script to do all the works.

#/bin/bash

for file in *.ogg; do
	oggdec $file
	file=$(basename $file .ogg)
	lame -h --vbr-new -V 2 "${file}.wav" "${file}.mp3"
	rm "${file}.wav"
done

I’m giving an option -V 2 to specify VBR quality of the result. 0 for highest and 9 for lowest quality.

Here’s a screenshot: