Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Mp3 lame bitrate compression optimization
1. AQuA Music
AQuA is the tool that will help you to save up to 40% on bitrate and
up to 50% on audio size when encoding your audio files!
AQuA for music quality testing is basically the same AQuA Wideband
product, which is devoted to perceptual testing of audio signal quality.
When considering digital recording and digital playback, sound quality
depends on the range of sound signal, the rate at which it is sampled,
and various conversions that occur in sound reproduction system.
In lossy codecs like MP3, sound quality is a factor that determines
how much of the sound signal data the encoder is allowed to loose
in order to reduce file size. In MP3-encoded signals for instance the
quality is defined by its bitrate, in kilobits per second (kbps).
The frequency range of sound (in Hertz) which equipment is capable
to sample and reproduce affects sound quality. Humans can hear
frequencies ranging from about 20 Hz to approximately 20 kHz, so
sampling that does not extend far enough will take effect on the
sound quality.
Sound signal wave is continuous and has some real value at every
instant. The digital quantization of the analogue sound wave means
that much of the continuous sound wave is not recorded. The rate
at which the sound is sampled refers to the amount of information
the detection equipment records for each second of the sound. The
higher the sampling frequency, the more accurate the final samples
will be. However, there is a mathematical proof that in order to
preserve all frequencies in the original sound it's enough that the
sampling frequency is two times higher than the highest frequency
in the sound signal spectrum. Thus for example when dealing with
speech one can easily use sampling frequency of 8kHz, because
human speech spectrum is limited by 4kHz and telephone channel
spectrum by 3.4kHz.
When recording a podcast, grabbing music from your CD into MP3,
2. OGG or AAC, uploading an audio book to your iPhone or dumping
your favorite tracks on a memory stick to play while driving, we
always face the same problem - we want to make the file smaller
but sound as good as ithe original. In many cases when one usess
MP3 encoder the choice he or she makes is simple - to use 320kbps
and that will surely preserve the quality. In many cases it may work,
but what if you store thousands of tracks? What if millions? What
if you are going to transmit your podcast over the Internet? What
if your audio is transmitted over a mobile network? In such cases
every megabyte saved turns into real money saving and the lower
the bitrate preserving desired audio quality the better performance of
your service.
The way it works is very simple. AQuA has a perceptual audio quality
model that acts as a very well trained human ear that can hear even
tiny changes in audio quality and tell how much quality was lost due
to audio processing. AQuA returns two types of scores:
- percentage of quality similarity compared to the original audio
- MOS (Mean Opinion Score), which is a value between 1 and 5
MOS Quality Impairment
5 Excellent Imperceptible
4 Good Perceptible but not annoying
3 Fair Slightly annoying
2 Poor Annoying
1 Bad Very annoying
So, the process of choosing the best audio compression parameters
(OGG, MP3, AAC compression optimization) when optimizing f.e.
bitrate with Lame MP3 encoder is split into the following phases:
1. set minimal bitrate = X
2. set bitrate incremental step = S
3. compress original audio into MP3 with bitrate X
4. decompress MP3 into uncompressed WAV
5. test quality comparing original WAV and uncompressed MP3 using
AQuA Wideband
6. if the quality is lower than MOS 5 increase bitrate so that new
3. bitrate = X + S and go to step 3
7. if the quality is higher or equals MOS 5 then we have found optimal
bitrate for this audio
Let's use MP3_Torture_Test.wav taken from this location: http://
recording.org/daw-pro-audio/28203-mp3-encoder-torture-test.html
We are going to use mp3opt.bat file to automate bitrate optimization
and the result we get is:
"% = 97.59"
"MOS = 5.00"
"Bitrate = 104"
"Passes=13"
So, we preserve 97.59% of original file quality if encode
MP3_Torture_Test.wav using Lame encoder with the following
parameters:
lame.exe -b 104 MP3_Torture_Test.wav MP3_Torture_Test.wav.mp3
In the post where we took the MP3_Torture_Test.wav from 128kbps
gives a very good quality according to the poster, but we could save
24kbps on bandwidth and about 400K on the file size!
lame.exe -b 128 MP3_Torture_Test.wav MP3_Torture_Test-
128kbps.wav.mp3
WAV 15882228 Bytes Bytes Ratio
128kbps 1441122 11
104kbps 1080842 15
Now it's time to check how much quality was preserved in the audio
compressed with 128kbps, so we use AQuA again:
aqua-wb tst.lic -mode files -src file MP3_Torture_Test.wav -tstf
MP3_Torture_Test-128kbps.wav -acr auto -npnt auto -miter 1 -enorm
on -grad on -mprio on -tmc on -ratem %m
4. Here is the output:
Sevana Audio Quality Analyzer - AQuA-Wideband v.5.3.11.720.
Copyright (c) 2009 by Sevana Oy, Finland. All rights reserved.
---------------------------------------------------------------
test license
---------------------------------------------------------------
File Quality is
Percent value 97.52
MOS value 5.00
Amazingly, but the quality is the same as at 104kbps! And if it sounds
the same (you are welcome to download these files and listen to
them yourself) why to spend extra space and bandwidth?
And now another application of AQuA Wideband – audio transcoding.
Let's compress MP3_Torture_Test.wav using Lame with 320kbps
keeping in mind that this is a typical choice of those who want to
preserve maximum of quality.
AQuA shows us that at 320kbps we preserved
aqua-wb tst.lic -mode files -src file MP3_Torture_Test.wav -tstf
MP3_Torture_Test_320kbps_mp3.wav -acr auto -npnt auto -miter 1 -
enorm on -grad on -mprio on -tmc on -ratem %m
Sevana Audio Quality Analyzer - AQuA-Wideband v.5.3.11.720.
Copyright (c) 2009 by Sevana Oy, Finland. All rights reserved.
---------------------------------------------------------------
test license
---------------------------------------------------------------
File Quality is
Percent value 99.50
MOS value 5.00
almost 100% of audio quality. Let's now transcode this audio file and
check what lowest bitrate we can use and how much quality we'll
preseve from 99.5%
5. "% = 97.53"
"MOS = 5.00"
"Bitrate = 104"
"Passes=13"
And we got a pretty much the same result from tanscoding. Of
course when dealing with uncompressed original audio we have a
better chance to avoid compression artifacts, but still it is possible to
transcode with a lower bitrate and audibly the same quality. Of course
compared to the original uncompressed audio we may get a different
result:
Sevana Audio Quality Analyzer - AQuA-Wideband v.5.3.11.720.
Copyright (c) 2009 by Sevana Oy, Finland. All rights reserved.
---------------------------------------------------------------
Valeri, test license
---------------------------------------------------------------
File Quality is
Percent value 97.41
MOS value 5.00
But it is still of a high quality level.
WAV 15882228 Bytes Bytes Ratio
320kbps 3602807 4.4
104kbps 1081469 15
After transcoding we saved 216kbps bandwidth and 70% of space!
What's in it for me?
Private customer (AQuA service) Corporate customer (AQuA Server)
Optimized audio CD grabbing Tremendous space saving on large
audio files
6. Increased storage on MP3 player, Space and bandwidth saving on
iPod and mobile devices podcasts, tunes, audio books hosting
and streaming
More audiobooks to fit the same Optimized audio for transmission
storage over communication channels
More tracks to fit the same Bandwidth saving on mobile network
memory stick audio streaming
Automated audio encoding with user
defined quality level
Optimize bitrate for Internet radio
broadcasting