The Mac OS X Guide to Ogg Vorbis
By (anom)
July 19, 2002
Note: This guide was written from and for a mac viewpoint, some issues will
not apply to other platforms.
Important: For the remainder of this guide, "vorbis" will mean Ogg Vorbis,
"aac" will mean the implementation of AAC in QuickTime 6.
Contents:
- What is vorbis?
- Why use vorbis?
- Encoder / Player support
- Installing vorbis from source
- Basic encoding with vorbis
- Miscellaneous / tips / tricks
1. What is vorbis?
"Ogg Vorbis is a fully Open, non-proprietary, patent-and-royalty-free,
general-purpose compressed audio format for mid to high quality
(8kHz-48.0kHz, 16+ bit, polyphonic) audio and music at fixed and variable
bitrates from 16 to 128 kbps/channel. This places Vorbis in the same
competetive class as audio representations such as MPEG-4 (AAC), and similar
to, but higher performance than MPEG-1/2 audio layer 3, MPEG-4 audio
(TwinVQ), WMA and PAC." - xiph.org
(Cnet recently posted a story Ogg Vorbis official release is here.)
2. Why use vorbis?
Advantages:
- Very high quality, superior to mp3 (even compared against the
--alt-presets) and aac.
- Fast encoding speed, 3x faster than encoding with the --alt-presets,
and slightly faster than encoding aac.
- Excellent native tagging system, no more ID3vX headaches.
- Uses true variable-bitrate (VBR) encoding, unlike aac, and also
supported managed bitrates for streaming applications.
- Supports bitrates from < 24kbps to > 500kbps.
- Supports multichannel, 16+bit, 48kHz audio.
- The format is open and free, unlike mp3 and mp4 there are no licensing
costs.
The list above summarizes the reasons why vorbis supercedes mp3 and aac.
However, there are a few caveats:
Disadvantages:
- Less support from software and hardware, though still more than aac.
- Few GUI tools.
- Fewer .ogg files on the internet (or is that a good thing?).
Q: But Apple's got AAC support in QuickTime 6, how does vorbis compare?
A: AAC in QuickTime 6 does sound good, but vorbis still produces higher
quality files, see the miscellaneous section. Also, aac does not use true
VBR, so quality differs throughout the audio file. Finally, vorbis supports
more bitrates, has its own tagging system and is supported by more audio
players.
3. Encoder / Player support
4. Installing vorbis from source
While the GUI applications listed above perform well, the most flexibility
and best performance is found only in the command-line tools. If you know a
scripting or programming language, you can easily write a script that
automates the encoding process depending on how you prefer to encode.
Important: You must have the OS X Developer Tools to perform these steps.
There are 3 build paths you can take, depending on your system configuration
and what you intend to do:
- Building from the standard distribution. This is the easiest way to
install ogg vorbis, but should NOT be used until version 1.0 is officially
released at vorbis.com.
- Building from cvs, with fink installed. If you have fink with
automake and autoconf installed, you can take this path to install vorbis
from the current developer code.
- Framework build / building from cvs, without fink. If you don't have
fink, or if you want to develop your own projects based on vorbis, you can
use this path to install vorbis as system frameworks.
1. Building from the standard distribution
1.1. Go to the download section of www.vorbis.com and choose the section
with UNIX files. Download libogg, libvorbis, libao, and vorbis-tools
packages.
1.2. In the Terminal, navigate to the libogg direcory and type:
./configure
make
sudo make install
1.3. Navigate to the libvorbis directory and type the 3 lines in step 1.2.
1.4. Navigate to the libao directory and type the 3 lines in step 1.2
1.5. Navigate to the vorbis-tools directory and type:
./configure --disable-ogg123
make
sudo make install
1.6. Type "rehash" or close the window and you are finished.
2. Building from cvs, with fink installed.
2.1. In the Terminal, type:
cvs -d :pserver:anoncvs@xiph.org:/usr/local/cvsroot login
(use "anoncvs" for the password)
cvs -d :pserver:anoncvs@xiph.org:/usr/local/cvsroot co ogg
cvs -d :pserver:anoncvs@xiph.org:/usr/local/cvsroot co vorbis
cvs -d :pserver:anoncvs@xiph.org:/usr/local/cvsroot co ao
cvs -d :pserver:anoncvs@xiph.org:/usr/local/cvsroot co vorbis-tools
Note: These files will be downloaded into the current directory.
Note: If you can't access the cvs server (down, etc) download the
nightly source archive
(
http://www.xiph.org/ogg/vorbis/download/vorbis_nightly_cvs.tgz).
2.2. Navigate to the ogg directory and type:
(Note: If the "./autogen.sh command produces an error in the initial
configuration phase, use "./autogen.sh ppc".)
./autogen.sh
make
sudo make install
2.3. Navigate to the vorbis directory and type the 3 lines in step 2.2.
2.4. Navigate to the ao directory and type the 3 lines in step 2.2.
2.5 Navigate to the vorbis-tools directory and type:
(Note: If the "./autogen.sh --disable-ogg123" command produces an error,
use "./autogen.sh ppc --disable-ogg123")
./autogen.sh --disable-ogg123
make
sudo make install
2.6. Type "rehash" or close the window and you are finished.
3. Framework build / building from cvs, without fink.
3.1. Download the code from cvs as shown in step 2.1.
3.2. Download the vorbis project file
(
http://homepage.mac.com/k_nakamura/OggVorbis.sit).
3.3. Place the ogg, vorbis, and vorbis-tools folders into the same folder as
the project file.
3.4. In the Terminal, navigate to the directory of the project file (do not
skip this step).
3.5. Type:
3.6. You are finished.
5. Basic encoding with vorbis
Note: For more help using OggEnc, type "oggenc --help".
The basic syntax for using oggenc is:
oggenc [parameters] [input file]
so you can do
and oggenc will produce a "foo.ogg" file in the same directory.
If you want to change the name or location of the output file, use the -o
parameter, so you can do
oggenc -o "~/Documents/bar.ogg" "~/Music/foo.wav"
and oggenc will output foo.wav to bar.ogg in the Documents folder.
If you want to change the quality settings of oggenc (from -1 to 10,
defaults to 3), use the -q parameter, so you can do
and oggenc will output foo.wav to foo.ogg at quality 4.5
If you want to constrain bitrates (for streaming, etc), use the -m and -M
parameters, to set min and max bitrates respectively.
If you want to add tags, use the -t, -a, -l parameters, so you can do
oggenc -t "TITLE HERE" -a "ARTIST HERE" -l "ALBUM HERE" foo.wav
and oggenc will add the title, artist, and album tags.
If you want to make the output filename based on the tags (very very
useful), use the -n parameter, so you can do
oggenc -t "Foo" -a "Bar" -n "%a - %t.ogg" foo.wav
and oggenc will output foo.wav to "Bar - Foo.ogg" with the appropriate tags.
If you want to resample files to a different sampling rate, use the
--resample parameter, so you can do
oggenc --resample 22050 foo.wav
and oggenc will resample foo.wav to 22050 Hz
6. Miscellaneous / tips / tricks
To easily see the superiority of the vorbis encoder (though this is an
unusual case) encode fatboy
(
http://lame.sourceforge.net/download/samples/fatboy.wav) at about 160 kbps.
Use a bitrate of 160 and joint-stereo for mp3, a bitrate of 160 for aac, and
quality level 2 for vorbis (produces 162kbps).
The quality settings roughly (for average files) match these bitrates (for a
stereo 44.1 kHz file)
Quality / Bitrate (kbps)
- -1 / 45
- 0 / 64
- 1 / 80
- 2 / 96
- 3 / 112
- 4 / 128
- 5 / 160
- 6 / 192
- 7 / 224
- 8 / 256
- 9 / 320
- 10 / 500
Note: In the reference to fatboy above, using quality level 2 produces 162
kbps when it normally produces roughly 96. This shows that the clip is very
difficult to encode and so the bitrate is raised significantly.
The following oggenc options produce files of ~ 32 kbps, good for streaming
oggenc -q 0.0 --resample 16000 --downmix inputfile.wav
Oggenc can encode audio straight from audio cds, but you must specify the -r
(raw) parameter
oggenc -r -o "$HOME/Music/Track 03.ogg" "/Volumes/Audio CD/Track
03.cdda"
If you want to normalize audio before encoding, download and install
(
http://www.cs.columbia.edu/~cvaill/normalize, ./configure, make, sudo make
install) "normalize". To use:
Note: The input file must be a .wav file, to easily convert aiff audio to
wav format, use the LAME mp3 decoder (
http://lame.sourceforge.net,
./configure, make, sudo make install).
lame --decode "/Volumes/Audio CD/Track 04.cdda" "$HOME/Music/Track
04.wav"
The following code is the interface I use to quickly rip, normalize, and
encode from cds. The tags are inputted as string through the console, and
the program/script just concatenates them together appropriately. Use these
ideas to automate the encoder to fit your needs.
#include <stdlib.h>
#include <iostream.h>
#include <fstream.h>
#include <string>
// The track numbers to be encoded are passed as parameters, ie. 03, 04, 12,
15, etc.
int main(int argc, char *argv[])
{
fstream settings;
string quality, encode, decode;
char temp[64];
int i, j;
system("clear");
// Load the quality settings from the file .ov_encrc at the root of the
drive.
settings.open("/.ov_encrc", fstream::in);
if(settings.good())
settings >> quality;
else
{
settings.close();
settings.open("/.ov_encrc", fstream::out);
settings << "4.0" << endl;
quality = "4.0";
}
settings.close();
// Input album tag.
cout << "Enter album name: ";
cin.getline(temp, 64);
encode = "oggenc";
encode = encode + " -q " + quality + " -l \"" + temp + "\"";
// How many different artists are there (1 for an artist's cd, >1 for
soundtracks).
cout << endl;
cout << "Number of artists: ";
cin >> j;
cin.sync();
// Input artist tags.
for(i = 1; i <= j; i++)
{
cout << "Enter artist " << i << ": ";
cin.getline(temp, 64);
encode = encode + " -a \"" + temp + "\"";
}
// Input track title tags.
cout << endl;
for(i = 1; i <= argc - 1; i++)
{
cout << "Enter title for track " << argv[i] << ": ";
cin.getline(temp, 64);
encode = encode + " -t \"" + temp + "\"";
}
// Set all the input and output files, do tag-based output.
encode = encode + " -n \"$HOME/Music/%a - %t.ogg\"";
for(i = 1; i <= argc - 1; i++)
encode = encode + " \"$HOME/Music/Track " + argv[i] + ".wav\"";
// Copy all tracks from cd to wave. Uses LAME to decode the audio.
cout << endl;
for(i = 1; i <= argc - 1; i++)
{
cout << "Copying track " << argv[i] << " from CD...";
decode = "lame --quiet --decode";
decode = decode + " \"/Volumes/Audio CD/Track " + argv[i] + ".cdda\"
\"$HOME/Music/Track " + argv[i] + ".wav\"";
system(decode.c_str());
}
// Eject the CD.
system("hdiutil load; hdiutil eject -quiet disk1");
// Normalize all audio.
cout << endl;
system("normalize -a -11dBFS $HOME/Music/*.wav");
// Encode everything.
cout << endl;
system(encode.c_str());
// Remove the wave files now that encoding is done, open the user's
music folder.
system("rm -f $HOME/Music/*.wav; open $HOME/Music");
return 0;
}
Other Audio Articles Welcome: Your articles on Mac Audio (OS X or otherwise)
are welcome. (I convert them all to HTML, so send the article as text in an email.)
Note: Thad Brown's been busy with other things over the last year
or so and I'm glad this column has gotten him some much deserved
recognition in the audio world. (See below
for links to Thad's 60 issues of the Audio column here.) I welcome
any reader submissions on the subject of Mac audio. If you have an
article or commentary to submit, please contact
me. Thanks!-Mike
Have an
Audio question? Check the Audio
FAQ first, then the General FAQ Audio topic area.
Audio Column
Back Issues:
- Independent Development of SBlive OS X drivers
- My Week w/Sister: The State of Mac OS X today [July 1, 2002]
- iPod Owner Reports on Reliability
- OS X MP3 Players - CPU load tests
- MP4 vs MP3 vs AIFF Audio Quality Tests
- Midiman Audiophile 2496 vs Mac SoundBlaster Live!
- Issue #68 Macworld SF 2002 Audio Report
- Issue #67 A Philosophy of Tweaking
- Reader Comments on Apple iPod
- Issue #66 Getting Serious on Budget Audio - Project Hammerfall
- Reader Reports on XITEL
USB/Digital Audio Adapter
- Mac SoundBlaster Live
Comments/Performance Tests
- Issue #65 Audio Apps with CPU Upgrades in Older Macs
- SoundBlaster
Live Report from MWSF
- Issue #64 Faster drive controllers/PC to Mac
Cubase Projects
- Issue #63 Absynth v1.0 Review
- T80 wireless headphones
- Issue #62 Mixing It Up (Mac Audio Mixers)
- Issue #61 Returning To Zero (reader opinion
piece)
Thad Brown's Past Issues:
- Issue #60 - Review of Reaktor 2.3.1 from
Native Instruments
- Issue #59 - Musikmesse Coverage
- Issue #58 - When Bad Things Happen To Good
Computers
- Issue #57 - Interview w/Stephan M. Sprenger
- Issue #56 - Stella900 Review
- Issue #55 - NAMM Show Report #2
- Issue #54 - NAMM Show Report #1
- Issue #53 - Thank You
- Issue #52 - Interview with Dan Phillips From
Korg USA!
- Happy End of the World (1999's end-of-year
issue)
- Emagic Releases The First Altivec Enhanced Pro
Audio App
- Holiday Gift Guide and More
- Unity DS-1 Review
- How to Buy a Sound Card
- News from the Audio Engineering Society Show
- A Few Disjointed Notes...
- Macworld and NAMM show wrapup
- Audio Industry News
- Price Cuts: Opcode Raises the Bar
- Better Hardware & New Software or More Of The
Same
- 1 Yr Anniv/Year in Review
- New Software and Cards!
- Choosing a new Audio system
- Vision DSP Review!
- Readers Talk Back
- TurboMax PCI IDE Performance
tests
- Hard Drives for Audio capture,
B&W G3 Audio
- News from NAMM (New
cards/apps/drivers)
- Where's my NAMM reporter?
- USB/Firewire Audio
- We're Back!
- Holiday Issue (Gift Ideas and
more)
- I've seen the Pulsar (more home
audio mastering Tips)
- Soft. Samplers, Audio interfaces
and Mastering at Home
- Comments on Mac Software/hardware
and Beos
- Review of Ray Gun (Audio
Restoration/Noise Reduction)
- OS 8.5 Audio/Disk problems, BeOS
audio player, Syquest Notes
- Cakewalk for Mac?, OS 8.5 disk
disasters and Cross-platform Audio
- More on the Midimand card, OS X,
iMac audio
- Optimizing your Mac for Audio
- Cheap Mac Audio Cards/iMac
Comments
- New Toys, AES '98
- Houston, we have a problem
- I feel your Pain
- SonicWORX Review!
- Studio Upgrade Special Report
- Back to Memphis
- USB/Toast Tricks/Cubase Notes
- 604 vs G3 Audio Specific Tests
- VIBRA 9000 and VIBRA 7000 Software Synth
- Studio Pro 98 Report
- The Toys Arrive
- Battle of the GUI
- Mpeg Audio Explained
- Industry News/Why Macs Rule
- Give the People What They Want
- AES Show news
- Mac Audio Resources/Links
- How Many Bits?
- Wither Mac Audio?
|