Importing MKV/AC3 Severe Clipping


Lately, I’ve been using Audacity to import MKV files (usually 448 kbps, 48 kHz, 6 channel, AC-3) and then compress the audio to 192 kbps stereo for a juicier headphone experience (surround does not play well with my mobile phone). I then use mkvtoolnix to mix the new audio back into the video file and everything sounds fine. However, today I encountered a problem I’ve never had before, and I’ve done this at least 200 times.

I imported an MKV with the above-mentioned audio parameters and it was clipping so badly the track was completely unusable. I’ve never seen anything like it. Normalizing the file did not help since the track was already ruined by distortion. However, while playing the MKV file using everything from VLC to WMP to Media Player Classic, the audio is just fine. In fact, it’s a little too quiet for my taste. I even used mkvtoolnix to extract the audio and listen to it separately and it was fine; no clipping. However, when I loaded the audio file by itself into Audacity, I experienced the exact same problem as loading the MKV. It’s almost as if Audacity is automatically amplifying the file at about +10 dB when it imports it. I checked the import/export options and “normalize all tracks in project” is unchecked and always has been. I then tested Audacity with a different MKV and everything was just fine.

Could there be a setting or a parameter I’m not familiar with which would cause an imported file to be amplified automatically?

Thank you.

Windows 10 Pro 64 bit
Audacity 2.2.2

It could be several things…

The original-imported data may not be clipped. Audacity can go over 0dB without clipping and some formats can go over 0dB without clipping (I’m not sure about AC3). You can try Amplifying by -1dB or so (attenuating). If Audacity still “shows red”, the peaks are going over 0dB (not clipping at 0dB).

Mixing is done by summation so the levels go up when you downmix to stereo. Most DVDs have plenty of headroom and there is a metadata field Dialnorm (dialog normalization) that adjusts the playback volume so if everything is done “correctly” you should be OK.

I don’t know if the FFmpeg decoder uses Dialnorm or if it ignores it. If Dialnorm is being ignored, that could account for the apparent amplification.

I don’t know if you are using the standard -3dB for the center and surround channels. (You’ll still get an overall boost because you are sill mixing/summing.) There is also metadata for this if the producers want to use something different, and again I don’t know if FFmpeg is reading and using that metadata.

Also, the LFE is supposed to be left-out of the downmix. If you include the LFE (“point one” channel), of course that will boost the downmix levels. The other 5 channels are supposed to contain the “regular bass” and the LFE is supposed to contain “extra” for “booms & explosions” and other effects.

I think the safest thing would be to export-to 32-bit floating-point WAV. Floating point can go over 0dB without clipping, so when you re-import Audacity may “show red”, but the waveform isn’t necessarily clipped. Then, re-import and normalize before exporting to MP3.

MP3 will make some peaks higher and some peaks lower so you’ll probably have to normalized to -1dB or so before exporting to MP3 if you don’t want to “see red”. MP3 can also go over 0dB without clipping, but you can still clip your DAC if you play-back at full-digital volume As far as I know, that slight clipping isn’t audible so it’s up to you.

Everything you’ve said makes complete sense. Every other movie I’ve downmixed has always had plenty of headroom and most times even allows for me to leave the LFE channel intact. However, what we are looking at in this photo is the untouched imported data. I have done no mixing or amplifying. Something is happening while the file is being imported that is automatically amplifying it to these levels that hasn’t happened with any other MKV or AC-3 file I’ve worked with before, and I haven’t changed any of my codecs. I know the original file is just fine because I can watch it with any one of my players and the audio sounds normal (got the codec from K-lite).

It’s only been with this one file and I haven’t been able to replicate the issue again, so maybe something was off with the way it was encoded? I honestly don’t know because my expertise is limited to importing, combining channels, and exporting (and sometimes attenuating when needed).

I discovered the issue is with specific AC3 files that don’t seem to be compatible with the older FFmpeg Library. I uninstalled both, wiped all Audacity files and folders from my system, upgraded to Audacity 2.3.2, and then installed FFmpeg 2.2.2. Everything is working perfectly now. Imported AC3 files are no longer clipping.