In this section, we will see how much information is changed or lost when we compress an audio file!
Using a kazoo, we first recorded a Happy Birthday tune on the kazoo which was saved as a 128kbps MP3 file of 336KB.
Using a simple series of python code given below, we decoded and re-coded this file to ultimately compress this audio file into an MP3 of 96kbps of file size 253KB and into an MP3 fof 32kbps with file size of 84.5KB.
#mp3 to pcm
ffmpeg -y -i HappyBirthday.mp3 -acodec pcm_s16le -f s16le -ac 1 -ar 16000 HappyBirthday.pcm
#pcm to wav
ffmpeg -f s16le -ar 8000 -ac 2 -i HappyBirthday.pcm -ar 44100 -ac 2 HappyBirthday.wav
#wav to 96-bit mp3
ffmpeg -i HappyBirthday.wav -vn -ar 44100 -ac 2 -b:a 96k HappyBirthday96pwm.mp3
#wav to 32-bit mp3
ffmpeg -i HappyBirthday.wav -vn -ar 44100 -ac 2 -b:a 32k HappyBirthday32pwm.mp3
Using Adobe Audition, we can compare two MP3 files of different bit rates by extracting the mathematical difference between the two.
First, let’s see a case where the two files are identical. Simply comparing the 32kbps file with itself, we see a flat silent waveform. If I play it, I don’t hear anything.
Now, let’s compare the 128kbps file with the 32kbps file. When we do that, we see that there is quite a bit of data here. If the files were similar, we wouldn’t see this much data. This is the amount of data missing in the 32kbps file.
Now, comparing the 128kbps and 96kbps files, we see that the data here is much less. This is because less data is lost here when we compress the 128kbps file to 96kbps as opposed to when we compress it to 32kbps. Again, if the files were similar, we wouldn’t see even this much data.