Wednesday, March 20, 2013

Nine different audio encoders 100-pass recompression test

Have you ever wondered how different codecs are affected by re-encoding / re-compressing? Of course, recompressing audio is a bad idea, but sometimes can't be avoided. Quality loss will inevitably occur, but are some codecs more resilient than others? To clear things up, I did a test with the following encoders:

Encoders used

  • WMA Professional 10 (wmapro), Expression Encoder 4
  • WMA 9.2 (wma), Expression Encoder 4
  • Musepack (mpc), mpcenc 
  • Fraunhofer Mp3 surround encoder (mp3s), mp3sencoder
  • LAME (mp3), lame
  • Quicktime AAC (qaac), qaac
  • Nero AAC (nero), neroaacenc
  • Vorbis OGG (vorbis), oggenc2
  • Opus (opus), opusenc

Encoder settings

I tested all encoders with default settings, except for the quality / bitrate setting. For the main test, I used quality-based VBR (variable bit rate) encoding. I set the quantifier for quality so that I approximated two quality levels, low (~96 kbps) and high (~256 kbps). For the detailed test, I added encodings using CBR (constant bit rate) and ABR (average bitrate).

I encoded the original sample with the respective encoder, decoded it back to WAV and encoded it again, for 100 times. For decoding, I tried to use the "official" decoder where available, for example I used neroaacdec for decoding Nero, and opusdec for decoding Opus. Then I listened to the results to determine which encoder produced the best results.

Results

AAC is the clear winner by far. It is virtually unaffected by the number of passes. All other codecs had degraded sound quality increasing with the number of encoding passes, especially at low bitrates.

At low bitrates, AAC was the only codec providing satisfactory results. All other encoders fall way behind and produce audible compression artifacts such as cracking noises, muffled sound and hissing. At high bitrates, LAME and Musepack can compete with AAC, but all other encoders fall behind.

It's interesting to see how much encoders profit from an increased bitrate when recompressing many times. For AAC, as the clear winner, it didn't matter. That being said, Musepack placed 9th with low bitrate settings, but at high bitrate, it was as good as AAC and was tied for 1st place. This is similar to LAME, which produced loud cracking noises at low bitrates and placed 6th, but sounded almost perfect at high bitrates and was tied for 1st place as well.

In contrast to LAME and Musepack, the Opus encoder was nearly unaffected by the bitrate. It produced very similar results at high and low bitrates, it also didn't lose too much quality from 10th to 100th pass. In the aspect of consistency, it's only second to AAC. However, consistency doesn't mean quality here, rather mediocrity from start to finish - it had a rough and distorted sound. To be fair, the Opus codec was designed for speech, not for delivering high fidelity music. The Fraunhofer MP3 encoder behaved similarly.

The different bitrate distribution modes (CBR, ABR and VBR) produced interesting results. VBR should, in theory, always result in the best possible quality. But at low bitrates, WMA and LAME actually sounded better in CBR mode, while adding loud cracking noises in VBR mode. WMA had the weirdest behavior in this aspect. At low bitrates, CBR sounds better than VBR, but at high bitrates, VBR sounds better than CBR. In reality, this didn't matter though, as WMA produced extremely poor results on any setting.

In general, WMA and the Fraunhofer MP3s codec were the most disappointing. WMA produced loud hissing and cracking noises, while the Fraunhofer encoder sounded bland and muffling, discarding brilliance and detail. The only reason Fraunhofer placed decent is that it doesn't produce loud cracking or hissing noises, which to my ears is even worse than just muffled or dull sound. Of course, that's purely subjective.

Some encoders did not only degrade sound quality, but also had some other quirks. For example, the LAME encoder lowers the volume with every encoding pass. The 100th pass was virtually inaudible. I had to normalize the audio to hear anything at all. Other encoders produced erroneous files and garbage. The Fraunhofer encoder added silence to the beginning and end of each file and repeated parts of the sample at the end. After 100 passes, it created a 12 seconds file (the original file was 7 seconds). Winamp and Foobar2000 even reported a length of 1:02 minutes for the Fraunhofer file, however the playback ended after 12 seconds. The Vorbis encoder did a similar thing, which resulted in a reported length of 2 seconds, while the playback ended at 7 seconds. I can't really say if I did something fundamentally wrong or if it's the encoders fault, but in the end, the Fraunhofer and Vorbis encoders produced corrupted files. For the listening test, I tried to fix all errors like added silence or corrupted files as I wanted to judge the sound quality only.

For the test sample, I used the first 7 seconds of Stripper Girl from Steel Panther, as it has both guitar and vocal sounds, nicely isolated from each other. I embedded all the sound files as HTML5 audio so you can hear the results for yourself. The samples are re-encoded as OGG Vorbis at high bitrate because most browsers won't play formats such as Musepack, Opus and WMA. Because the samples are re-encoded, they are not 100% accurate, but this inaccuracy is negligible.

Results by codec (100 passes, from best to worst)

For the sake of brevity, this table only contains VBR results after 100 passes. For results after 10, 25 and 50 passes, as well as CBR and ABR results, scroll to the bottom of this page.
VBR, low quality (~96 kbps)
# Original (WAV)
The original. For the web page player, I encoded it as OGG Vorbis ~230kbps which should be transparent.
1 AAC (Nero)
The clear winner. Very clear sound and minimal quality degradation after each pass. After 100 passes, it sounds almost the same as after 10 passes.
2 AAC (Quicktime)
Almost as good as Nero, but has some clicks added (listen closely to the beginning of the 2nd guitar chord).
3 Opus
As you will hear, it gets a lot worse from here. Opus delivers a rough sound with audible distortions.
4 MP3 (Fraunhofer Mp3s)
Lost a lot of detail, very muffled, but no hissing or cracking noises.
5 OGG Vorbis
Muffled, hissing noise
6 MP3 (LAME)
Retained some detail and is not as muffled as others, but adds a loud, sharp hissing noise
7 WMA
Very prominent hissing noise
8 WMA Professional
Like WMA, but a little worse
9 Musepack
Musepack comes in last. Sounds like a radio with no antenna.
VBR, high quality (~256 kbps)
# Original (WAV)
The original. For the web page player, I encoded it as OGG Vorbis ~230kbps which should be transparent.
1 (tie) AAC (Nero)
Again, very clear sound and minimal quality degradation after each pass.
1 (tie) AAC (Quicktime)
As good as Nero
1 (tie) MP3 (LAME)
LAME very much benefits from the added bitrate. There's no more cracking noises. It sounds as good as AAC.
1 (tie) Musepack
As good as AAC
5 Vorbis
Retained some detail and crispness, but has a garbled, glitchy background noise
6 Opus
Rough sound with audible distortions
7 Fraunhofer MP3
The added bitrate didn't help. Still very muffled and no detail.
8 WMA
Not muffled but loud cracking noises
9 WMA Professional
Like WMA

Detailed results:

    • Original (WAV)
      cbr, high quality
      cbr, low quality
      abr, high quality
      abr, low quality
      abr, med quality
      vbr, high quality
      vbr, low quality
    • Original (WAV)
      cbr, high quality
      cbr, low quality
      abr, high quality
      abr, low quality
      vbr, high quality
      vbr, low quality
    • Original (WAV)
      vbr, high quality
      vbr, low quality
    • Original (WAV)
      cbr, high quality
      cbr, low quality
      vbr, high quality
      vbr, low quality
    • Original (WAV)
      cbr, high quality
      cbr, low quality
      vbr, high quality
      vbr, low quality
      abr, high quality
      abr, low quality
    • Original (WAV)
      cbr, high quality
      cbr, low quality
      vbr, high quality
      vbr, low quality
      abr, high quality
      abr, low quality
    • Original (WAV)
      cbr, high quality
      cbr, low quality
      abr, high quality
      abr, low quality
      vbr, high quality
      vbr, low quality
    • Original (WAV)
      cbr, high quality
      cbr, low quality
      vbr, high quality
      vbr, low quality
      abr, high quality
      abr, low quality
    • Original (WAV)
      cbr, high quality
      cbr, low quality
      abr, high quality
      abr, low quality
    • Original (WAV)
      cbr, high quality
      cbr, low quality
      abr, high quality
      abr, low quality
      abr, med quality
      vbr, high quality
      vbr, low quality
    • Original (WAV)
      cbr, high quality
      cbr, low quality
      abr, high quality
      abr, low quality
      vbr, high quality
      vbr, low quality
    • Original (WAV)
      vbr, high quality
      vbr, low quality
    • Original (WAV)
      cbr, high quality
      cbr, low quality
      vbr, high quality
      vbr, low quality
    • Original (WAV)
      cbr, high quality
      cbr, low quality
      vbr, high quality
      vbr, low quality
      abr, high quality
      abr, low quality
    • Original (WAV)
      cbr, high quality
      cbr, low quality
      vbr, high quality
      vbr, low quality
      abr, high quality
      abr, low quality
    • Original (WAV)
      cbr, high quality
      cbr, low quality
      abr, high quality
      abr, low quality
      vbr, high quality
      vbr, low quality
    • Original (WAV)
      cbr, high quality
      cbr, low quality
      vbr, high quality
      vbr, low quality
      abr, high quality
      abr, low quality
    • Original (WAV)
      cbr, high quality
      cbr, low quality
      abr, high quality
      abr, low quality
    • Original (WAV)
      cbr, high quality
      cbr, low quality
      abr, high quality
      abr, low quality
      abr, med quality
      vbr, high quality
      vbr, low quality
    • Original (WAV)
      cbr, high quality
      cbr, low quality
      abr, high quality
      abr, low quality
      vbr, high quality
      vbr, low quality
    • Original (WAV)
      vbr, high quality
      vbr, low quality
    • Original (WAV)
      cbr, high quality
      cbr, low quality
      vbr, high quality
      vbr, low quality
    • Original (WAV)
      cbr, high quality
      cbr, low quality
      vbr, high quality
      vbr, low quality
      abr, high quality
      abr, low quality
    • Original (WAV)
      cbr, high quality
      cbr, low quality
      vbr, high quality
      vbr, low quality
      abr, high quality
      abr, low quality
    • Original (WAV)
      cbr, high quality
      cbr, low quality
      abr, high quality
      abr, low quality
      vbr, high quality
      vbr, low quality
    • Original (WAV)
      cbr, high quality
      cbr, low quality
      vbr, high quality
      vbr, low quality
      abr, high quality
      abr, low quality
    • Original (WAV)
      cbr, high quality
      cbr, low quality
      abr, high quality
      abr, low quality
    • Original (WAV)
      cbr, high quality
      cbr, low quality
      abr, high quality
      abr, low quality
      abr, med quality
      vbr, high quality
      vbr, low quality
    • Original (WAV)
      cbr, high quality
      cbr, low quality
      abr, high quality
      abr, low quality
      vbr, high quality
      vbr, low quality
    • Original (WAV)
      vbr, high quality
      vbr, low quality
    • Original (WAV)
      cbr, high quality
      cbr, low quality
      vbr, high quality
      vbr, low quality
    • Original (WAV)
      cbr, high quality
      cbr, low quality
      vbr, high quality
      vbr, low quality
      abr, high quality
      abr, low quality
    • Original (WAV)
      cbr, high quality
      cbr, low quality
      vbr, high quality
      vbr, low quality
      abr, high quality
      abr, low quality
    • Original (WAV)
      cbr, high quality
      cbr, low quality
      abr, high quality
      abr, low quality
      vbr, high quality
      vbr, low quality
    • Original (WAV)
      cbr, high quality
      cbr, low quality
      vbr, high quality
      vbr, low quality
      abr, high quality
      abr, low quality
    • Original (WAV)
      cbr, high quality
      cbr, low quality
      abr, high quality
      abr, low quality

1 comment:

  1. Interesting.

    However, as a real codec torture test, I'd recommend you to do the following before each pass:
    * Change speed randomly (within a range of +/- 20% so it'll not cut out audible frequencies at 48 kHz)
    * Change volume randomly (+/-20%)
    * Add some sound of random duration at both start and end (0.05 to 0.15 seconds each) - use actual sound and no silence as codecs might just cut that out

    And after decompressing the compressed data undo the above steps.

    ReplyDelete