Home | Blog | Links | Contact | FAQ

Audio formats

http://wiki.slimdevices.com/index.cgi?BeginnersGuideToFileFormats
http://wiki.slimdevices.com/index.cgi?CodecComparison

Music and all other digital media is stored in files. Because it's not very effective to use untranslated files like the way they are stored on CD's, they have to be encoded. Major advantage is the reduced file size. There are several encoding scheme's or file formats. The one that's best known is MP3, but there are many more: ogg, flac, wma, aac, ape to name a few. Each one is associated with a different codec (which stands for: Compressor-Decompressor, i.e. the program which creates or reads the file). Many different codecs exist because they all differ in file size or compression rate and quality optimisation.

We shall name all the critera at which each coded can be judged. We also give you a recommendation of which codec is best to best used in a given situation.

Lossless vs. lossy

One important purpose of a file format or codec is compression. The higher the compression rate, the smaller the files are. Compression can be achieved in two ways: with or without losing information.

The advantage of encoding with losing information, 'lossy', is that compression can be enhanced to very high ratings.. A typical compression ratio of ten can be reached, which means that the music of up to ten CD's can fit on one single CD after encoding. That's nice, but the counterpart is that audio information that can't be heard by the human ear is thrown away. In most situations, like listening on your portable audio player, differences are not hearable, so this is acceptable in that given situation. Examples of lossy formats are mp3 and ogg.

However, this changes dramatically when you are listening to your encoded music on a (very) high quality audio system, in which every little detail is important: then, any loss of musical information is easily detected.

Also, transcoding from a lossless format to a lossy format doesn't throw information away, no more than ripping directly from the source (CD). A lossless format is one which doesn't lose any information compared to the original, the codec works the same as for example zip, a generic compression utility for computer files. It is even possible to recreate an original audio CD right from the lossless files! Examples of lossless formats are flac and wav.

Each person has different ears, so each one can hear different things. Discussion about hearing differences can take easily many hours. However, one thing is certain: every loss of information is detectable, it all depends on the quality of your audio equipment. If one cannot distinguish differences between several audio formats in a given listening situation, just upgrade the equipment (speakers, amplifiers, etc.) and quality degradation becomes imminent.

Quality level (bitrate)

Every codec has some kind of quality level. Some reflects audio quality (lossy codecs like mp3), some reflect compression ratio (lossless codecs like flac). When looking better into lossy codecs, we can determine the bitrate property. Each lossy codec (mp3, ogg) is encoded against a certain bitrate. This bitrate can be constant (CBR) or variable (VBR). In the latter case, algorithms in the encoder determine for each fragment the optimal bitrate.

Bitrate Is measured in kbits/sec and simply says how much data there is in a stream. The higher the bit rate, the higher the quality. For example a 320kbit/s mp3 is generally held to be of very high quality, 128kbit/s more ordinary. But beware, you can't directly compare two different formats in this way, as the sound quality depends also on the ability of the encoder to get the important bits right.

The higher the bitrate, the higher the quality level is, but also, as a tradeoff, the larger the files will become. When endoding, you should detremine what bitrate is best for you, it's always a delicate balance between quality and file size.

Compatibility

If you want to be able to play your files in multiple places (e.g. on a software player, on a portable audio player or through Squeezebox) then you'd ideally like to have one format to do all of them. Unfortunately, not all software players (Winamp or Windows Media Player) do not support all codecs out of the box. Sometimes it's possible to load some additional codec-pack, but that's not always the case; then you're stuck with the predefined codecs.

The same is for portable audio players (iPod and the like). If the player isn't supporting a certain codec as a standard, it is next to impossible to get him playing that codec. However, if you're willing to experiment, you can look into projects like Rockbox or iPodLinux.

It looks like there may be no acceptable compromise between "top quality" for your home audio listening and "small size" for your portable. Many people rip into multiple formats at once for the different uses (and that's exactly what we are doing within the 3A concept, namely on-the-fly transcoding from lossless to lossy).

Tags

You will almost certainly want your music files to contain information (e.g. Artist, Album, Title etc) in Tags. Most file formats will manage this - but not WAV.

Comparison

FLAC (Free Lossless Audio Codec)

FLAC is a free open-source lossless audio codec:

+ Lossless
+ Freeware and OpenSource
+ Supported natively by SlimServer / SqueezeBox
+ Supports Vorbis-style tags
+ No DRM protection
- Most hardware and some software players don't support FLAC

http://en.wikipedia.org/wiki/Flac

OGG

- Takes longer to encode then mp3

MP3

Lame is a well developed and tested free MP3 codec that is highly recommended if MP3 is the desired file format. Here is more information on setting up lame. Lame is:

+ Freeware and OpenSource
+ Heavily tested
+ Compatible with almost all players
+ Supports Id3-style tags
+ No DRM protection
- Lossy

http://en.wikipedia.org/wiki/MP3

AAC (Advanced Audio Coding)

AAC is a lossy codec that is sounds good at low bitrites (small file sizes) and is supported by Apple on its iPods and in its iTunes application:

+ Freeware
+ Supported by iPod and several other hardware players
+ Supports proprietary
+ Supports tagging
- Lossy
- May contain DRM protection
- Must be transcoded (automatically) to play on SlimServer

http://en.wikipedia.org/wiki/Advanced_Audio_Coding

ALAC (Apple Lossless Audio Codec)

Apple's lossless MPEG4 audio encoder is called ALAC and it outputs files with the extension .m4a.

+ Lossless
+ Freeware
+ Supported by iPod and some other physical players
+ Supports tagging
- May contain DRM protection
- Must be transcoded (automatically) to play on SlimServer

http://en.wikipedia.org/wiki/ALAC

WMA (Windows Media Audio)

+ Both Lossy and Lossless (WMA Pro) support (as of version 9)
+ Freeware
+ Supported by many non-iPod hardware digital audio players
+ Supports tagging (though the tags are non-standard)
- May contain DRM protection

http://en.wikipedia.org/wiki/Windows_Media_Audio

WAV (Waveform)

+ Lossless
+ Supported by virtually all players and editors
+ Played natively by SlimServer
- No tagging support (Wav64 does support tagging)
- Uncompressed (thus large file sizes)

http://en.wikipedia.org/wiki/Wav

Recommendations

Here is where it gets contentious, no arguing here please!!
FLAC is a good all-round choice: lossless, native in Squeezebox 2 and 3
If you want to use the same files in an iPOD, consider AAC or AAC lossless
Similarly if you have a need to use the same files in another player, go with what works in most places for you
don't forget that its fairly easy to change from one lossless format to another - so if in doubt, pick one! You can change your mind later without losing quality. But if you start with a lossy format, you can never get back to the original without re-ripping
High bit rate (say 320 kBit/s) MP3 are pretty darned good and will play in almost anything
Don't be afraid to rip in multiple formats for different uses. You should be able to automate this easily.

  • Describing the process: ripping, encoding, tagging
  • What is a codec?
    • Lossless vs. lossy
    • Open vs. closed
      • open formats:
        • are standard in open source systems like Linux
        • are not standard in closed source systems like Windows or Apple because of a hidden business agenda:
          • Windows -> WMA
          • Apple -> AAC
        • are always DRM free
        • are often technological better then closed alternatives
      • closed formats are standard in closed source systems like Windows
        • suffer from patents (mp3)
          • for this reason, they cannot be build standard in a open source system
        • tend to have DRM (wma, aac)
    • wav, mp3, ogg, flac, wma, aac, ...
      • comparision matrix (features, open/closed, lossless/lossy, etc.)
      • preferences (flac, ogg)
    • comparison between ogg vs. mp3
      • quality vs. file size
      • A scientific approach: http://www.extremetech.com/article2/0,1697,1560783,00.asp
  • tagging
  • What is DRM
    • Digital Rights Management = Digital Restrictions Management
    • Steer away from DRM! (blog)


MP3 Licensing
[mp3licensing.com]
Ogg Vorbis [vorbis.com]
Codecs Forum [hydrogenaudio.org/forums]

Advanced Audio Architecture