Creative Commons License This work is licensed under a Creative Commons License

Back to main page

The Quick-n-Dirty Guide to Converting AC3 Audio to OGG Vorbis

Revision 1.0.0 - see ChangeLog

Introduction

This guide demonstrates how to convert audio from AC3 format to Ogg Vorbis, MP3, and other compressed audio formats. If you have questions or comments, please email them to jmglov***replace_with_at-sign***wmalumni.com.

Installation

For the process described in this guide, you will need the following software to be installed:

For help on installation, see "The Quick-N-Dirty Guide to Finding and Installing Software" or your distribution's documentation.

Conversion

Converting a file from the AC3 format to any other music format is a two-step process. First, you must decode the AC3 audio into plain PCM data (also known as WAVE or WAV). Then, you encode the PCM data into the compressed audio format of your choice (and I recommend choosing Ogg Vorbis).

For example, let's say you have an AC3 file named foo.ac3 that you want to encode into Ogg Vorbis format. To decode the AC3 audio to plain PCM, use the a52dec tool:

a52dec -o wav foo.ac3 >foo.wav
Do not forget the redirection operator, '>', or a52dec will happily spew binary data all over your terminal! Now, to encode this file into Ogg Vorbis format, use the oggenc tool, which is part of the vorbis-tools package, mentioned above in the Installation section of this guide. The only arguments you need are:
oggenc -b 192 -o foo.ogg foo.wav
The -b 192 option tells oggenc to use a target bitrate of 192kbps (note that the Ogg encoder uses a psychoacoustic analyser to adjust the bitrate dynamically). You should feel free to adjust this--the higher the number, the better your audio will sound, but the larger the file will become. For encoding source audio that was encoding in AC3, I do not recommend choosing a bitrate less than 192kbps. Alternatively, you could use the -q n option instead of -b n, to tell oggenc to aim for a specific quality. With AC3 source audio, I would recommend using -q 5 for encoding.

oggenc has many options that give you more control over the encoding process. To learn about them, read the man page by running:

man oggenc
Some of the more useful options have to do with setting the ID tag data. For example, if I rip the audio of a live performance of Neil Young's "Rockin' in the Free World" from a DVD, I would convert it to Ogg Vorbis thusly:
a52dec -o wav "Neil Young - Rockin' in the Free World.ac3" \
  >"Neil Young - Rockin' in the Free World.wav"
oggenc -b 192 -o "Neil Young - Rockin' in the Free World.ogg" \
  -a "Neil Young" -G "Rock" -d "1989/02/21" -N 17 \
  -t "Rockin' in the Free World" \
  -l "Freedom Tour 1989 - Live at the Paramount Theater in Seattle - 1989/02/21" \
  "Neil Young - Rockin' in the Free World.wav" && \
  rm "Neil Young - Rockin' in the Free World.wav"
Just to walk you through this:

On the off chance that you want to convert your AC3 audio into poor-sounding, proprietary MP3 format, here's how:

a52dec -o wav foo.ac3 >foo.wav
lame -b 256 foo.wav foo.mp3 && \
  rm foo.wav
Or, to re-use my Neil Young example for nice ID tag writing:
a52dec -o wav "Neil Young - Rockin' in the Free World.ac3" \
  >"Neil Young - Rockin' in the Free World.wav"
lame -b 256 --ta "Neil Young" --tg "Rock" --ty "1989" --tn 17 \
  --tt "Rockin' in the Free World" \
  --tl "Freedom Tour 1989 - Live at the Paramount Theater in Seattle - 1989/02/21" \
  "Neil Young - Rockin' in the Free World.wav" \
  "Neil Young - Rockin' in the Free World.mp3" && \
  rm "Neil Young - Rockin' in the Free World.wav"

Obviously, you can encode the audio to any compressed format you would like, once you have decoded the AC3 file with a52dec. Some other formats worth looking at are:

ChangeLog

1.0.0

Back to main page