# Are common formats and encoders of lossy audio compression idempotent?

That an action is “idempotent” means if you do it several times, the effect is the same as if you do only once.

Lossy audio compression by definition loses information. Even if you convert it back to a WAV file, there will be differences from the original. However, what if you convert a WAV to MP3 and back, and then repeat the process many times, does the audio quality keep degrading before reaching some stable point, or does it not degrade further as MP3 is theoretically already able to hold that much information?

I guess the situations might be different for different formats and different encoders, so it may be a broad question.

• I suggest that this question belongs to dsp.stackexchange. Apr 3, 2022 at 6:06
• What practical problem is this trying to solve? If in theory the answer is 'yes' why would anyone cycle the exact same parameters each time repeatedly? If the practical issue is whether many transformations by many people at many different times by many different methods would affect the result [like some dodgy fake FLAC downloaded off the interweb], then the practical answer will be 'no'. Apr 3, 2022 at 18:48

## 2 Answers

For the AAC codec built into MATLAB, I guess that the answer is "no". The squared error never completely converge, after about 15 iterations it starts to oscillate between two values for this particular test (I did a simple test to confirm delay behaviour, but this test is crude)

fs = 48e3;
x{1} = (2*rand(fs,1)-1);
fname = 'test.mp4';
sqe(1) = (x{1}-x{1})'*(x{1}-x{1});
for it = 2:40
audiowrite(fname, x{it-1}, fs, 'BitRate', 48);
x{it} = audioread(fname);
sqe(it) = (x{it}-x{1})'*(x{it}-x{1});
end

figure,
plot(sqe(2:end))
xlabel('iteration')
ylabel('square error')


I tried this out using the bash script below.

ffmpeg -i audio-max-quality.aifc -vn -ar 44100 -ac 2 -b:a 192k audio-1.mp3
ffmpeg -i audio-1.mp3 audio-1.wav

for ITER in $$( seq 1 1000 ) do NEXT=$$((ITER+1))
ffmpeg -i audio-$$ITER.wav -vn -ar 44100 -ac 2 -b:a 192k audio-$$NEXT.mp3
ffmpeg -i audio-$$NEXT.mp3 audio-$$NEXT.wav
done


I've probably not done the right thing, but even after about 150 iterations, the audio was barely audible.