Request: ffmpeg plugin with drc_scale disabled

During import of ac3 files, audacity’s ffmpeg has -drc_scale set to 1, which does a bad dynamic range compression and lowering the volume. I worked on a project like this but noticed it too late. For an audio editing software, this is not acceptable. Would any of you be willing to complile a version of audacity’s ffmpeg plugin with -drc_scale set to 0 by default? I believe this is a better solution than editing raw audacity code.

1 Like

Using compressed audio formats during production is one of the cardinal sins for professional audio production. Don’t you have an uncompressed version of the source material to work with?

Please explain what the problem is in more detail.
If I encode as AC3 on export from Audacity (with high bit rate to reduce losses), and then import that AC3 file back into Audacity, I’m not seeing any dynamic range compression, so I’m unsure what problem you are referring to.

Hi steve,
the audio I’m editing is from a DVD and as such I’m limited to using the compressed ac3 files from that DVD. What I’m doing is I sync audio tracks from a low quality cut video source to a high quality uncut video source.

Audacity/ffmpeg doesn’t apply dynamic range compression on file export. As such, own created AC3 files don’t have the DRC issue. AC3s from commercial DVDs are affected. Allow me to show you using screenshots:

  1. Direct AC3-Import:


    This shows the wave form when importing a commercial AC3 directly in Audacity. It’s dynamic range compressed and has a lower volume. If you play the source AC3 in a media player, you will notice that the audio is much louder and clearer than the file imported in audacity.

  2. DRC manually removed → converted to wave → imported in Audacity


    This shows the wave of the same AC3 that has been converted to wave first with the -drc_scale flag set to 0 using ffmpeg. As you can see, the wave is a lot bigger than the first one and if you play it, it sounds exactly like the source ac3.

What this means is that Audacity always produced a lossy export of commercial ac3s when users intended a lossless one. All this time during working on my project I didn’t notice this issue because I was expecting Audacity to do its job properly. To be fair, it could be argued that the blame partly falls on ffmpeg because ffmpeg sets -drc_scale to 1 by default if you don’t tell it to set it to 0, yet Audacity had plenty of time to fix this issue on the audacity side via a simple code edit.

This shows the wave form when importing a commercial AC3 directly in Audacity. It’s dynamic range compressed and has a lower volume.

I don’t know what FFmpeg is doing but the top-smaller waveform looks MORE dynamic (less compression).

The bottom waveform appears to be limited. The peaks are all the same.

I think this could be argued either way. DVD players default to using the Dolby dynamic range compression when present, and DVD makers choose how much dynamic range compression will be used by default. Disabling drc_scale causes playback to be different from what was intended by the makers of the DVD as they will expect their specified dynamic range compression to be used by default.

On the practical level, when ripping a DVD, does your DVD ripper not have the option to rip to WAV? Does the DVD ripper not have an option to ignore the Dolby DRC?

I guess the ideal solution would be for Audacity to provide an option for the drc_scale setting, though I’m inclined to think that the default should be as it is now.

I don’t think it was intended by the makers for the audio to be played in very low volume and obviously very compressed sounding. The raw AC3 plays just fine when played by basically all media players. It’s only when you import it in audacity, it’s when the quality degrades a lot. I finished my project using audacity unbeknownst of the drc_scale issue and all my videos sound worse than the source videos/source DVDs.

I rip DVDs losslessly with makemkv and extract AC3 files losslessly from mkvs with mkvcleaver. As I said, now that I know of the drc_scale issue, I always convert AC3s with ffmpeg to proper waves with drc_scale disabled before importing them in audacity, but this step should be included in audacity’s ac3 import function imo.

An option for drc_scale is a possibility, but the default should never be as it is now because drc_scale literally has only disadvantages. There is nothing to lose if you disable drc_scale, only things to gain. Files that don’t have DRC ignore the drc flag and import as usual and files with drc will import in their full quality. Audacity prides itself in being the best audio editing software, so it only makes sense that it would import AC3s in their full quality and not in a compressed state. Please disable drc_scale in Audacity’s AC3 import function. The code is already there.

Then why did they do it?

According to Sony, the compression makes the audio louder :confused:

The following are explanations for each setting:

Standard: This mode takes the widest dynamic range (the difference between the quietest and loudest sounds).
Because signals are played back directly, quiet signals remain quiet and loud signals remain loud.
Compressed: This mode compresses the volume difference and increases the overall volume.
The audio is easier to hear, regardless of the dynamic range of the sound source.

NOTE: This setting affects Dolby Digital, Dolby Digital Plus, and Dolby AC-4 sound sources.


I’m rather surprised by that as Google tells me that people complain about this same issue in other media players.
I don’t have experience of this myself as I don’t rip DVDs.

I’ve just looked in VLC and I see that it has “A/52 dynamic range compression” enabled by default.


If you are exporting in a compressed format, then some degradation is inevitable, simply because the audio has been subject to lossy compression twice.

No idea. Maybe it’s something that the official AC3 tool companies use does to the audio when making it Dolby Digital AC3. Thing is, only AC3 has this issue. AAC for instance, doesn’t have this issue.

Look, I don’t care what Sony says. All I can do is trust my eyes (the wave form is smaller) and trust my ears (the sound is quiter) of AC3s directly imported in Audacity.


I never use VLC for anything but I just checked my stock install and it has Dynamic Range Compression disabled by default:

That’s a different issue you’re describing. I export AC3s to WAVE after editing as to not further degrade the audio (but even if I compress back to lossy, I would not be able to hear a difference tbh). What I meant by saying my videos sound worse than the source videos is precisely the issue we were talking about all the time: The DRC Scale issue.

Look man, Audacity is not an audio player, it’s an advanced audio editing tool. Why would you allow audio to be edited in a compressed state in audacity? Doesn’t it make more sense to uncompress audio to its fullest for best editing? Isn’t that why Audacity works with Waves only? What’s the point of the Waves when they are affected by compression? If people want to apply DRC to their ac3 exports, they can always chose to do so in post processing.

I attached 2 sample files, the first one is the one Audacity processed with DRC Enabled, the second one with DRC Disabled. Hear for yourself.
DRC_ON.ac3 (593 KB)
DRC_OFF.ac3 (593 KB)

Interesting. Have you tried measuring the crest factor of those samples?

No, I’m not familiar with that. What’s the point anyway?

Just registered to add my voice to this request. As far as I can tell, it looks like it was fixed for the 3.x code, but then reverted. Any idea on when this change will make it to a release?

It should be fixed when FFmpeg is updated, because FFmpeg now sets drc_scale to disabled by default.
The update for Audacity to support later versions of FFmpeg was reverted due to concerns regarding compatibility.
I don’t know when FFmpeg support will be re-updated as there has been no announcement about that.

Cool. Thanks for the update!

I just download the new 3.0.3 64-bit release and drc_scale is still at 100%. Is this something that will be fixed or not?

Watch this issue: Add support for modern FFMPEG versions · Issue #1466 · audacity/audacity · GitHub

Will do. I was thinking that someone could have made the change when compiling the 64-bit version of the library, but realized after I posted that you probably meant that this will be fixed when they make the BIG change to FFmpeg support and not just reving the existing library.

The good news is that it is such a simple change, it can be made just by modifying two bytes in the existing dll. The default value is defined in ac3dec.c as below.

In “libavcodec\ac3dec.c” lines 1549-:

static const AVOption options[] = {
    { "drc_scale", "percentage of dynamic range compression to apply", OFFSET(drc_scale), AV_OPT_TYPE_FLOAT, {.dbl = 1.0}, 0.0, 6.0, PAR },

The structure defining the defaults is easy enough to find in the binary using a hex editor, and the DRC default of 1 (0x3ff0000000000000) can be zeroed out, turning DRC off.

I would happy to upload a patched binary of “avcodec-55.dll” so this fix could be used by other people, but the forum does not allow me.

Since I cannot upload the patched file, I thought I could at least show exactly what needs to be changed. The attached screenshot points out exactly which bytes need to be modified (for the 64bit version of avcodec-55.dll). To completely disable DRC, change “F0 3F” to “00 00”. To set the scale to 50%, change “F0 3F” to “E0 3F”.
avcodec-55.dll.HxD_mod.png

Where is that in the Audacity code?

It is in the ffmpeg 2.2.2 code. This hack just changes the default value ffmpeg uses for the drc_scale option.