Log in

View Full Version : ffmpeg ac3 vs eac3 - any difference?


bokeron2020
6th September 2021, 22:57
Hi.

I've been doing some encodes at different bitrates and ABX tests. My results show no audible improvement using EAC3 at the same bitrate compared to the supposedly less capable AC3.

The difference do exist... but I had to phase invert and check cancellation to find it.

So my question about EAC3 and ffmpeg's EAC3 is...


Is ffmpeg's EAC3 implementation just an AC3 with minor changes?
A bad implementation of EAC3?
Or is there really no quality difference between EAC3 and AC3 for the same bitrate/channels even using professional codecs and comparing between them?

junh1024
7th September 2021, 02:59
What bitrates did you test?

I'm guessing it shold show some difference for music @ 64-160kps stereo, but I haven't done any tests for DDP myself.

EBU testing https://tech.ebu.ch/docs/tech/tech3324.pdf (p21) has shown DDP 256kps almost matches DD 384kps on surround, but this is on professional encoders.

bokeron2020
7th September 2021, 06:02
What bitrates did you test?

I'm guessing it shold show some difference for music @ 64-160kps stereo, but I haven't done any tests for DDP myself.

EBU testing https://tech.ebu.ch/docs/tech/tech3324.pdf (p21) has shown DDP 256kps almost matches DD 384kps on surround, but this is on professional encoders.

I've tested 192 kbpps - 256kbps - 384kbps

No difference that I can hear at least, after lots of ABX, comparing ffmpeg's AC3 vs. EAC3 at same birate.

This implementation of EAC3 offers nothing like what that EBU test shown in 2007, rendering useless for my needs (5.1 channels).

So I was wondering if someone can confirm my results... if someone here is using ffmpeg and not dolby encoder engine or similar commercial encoders.

junh1024
7th September 2021, 07:55
I've tested 192 kbpps - 256kbps - 384kbps


Too high. You need to go lower.

DD vs DDP is roughly anagulous to AAC & HE-AAC, and like all lossy codecs, comparisons are useless if the bitrate is too high.

richardpl
7th September 2021, 08:47
Isn't this about >6 channel support in EAC3 encoder?

tebasuna51
7th September 2021, 10:31
Isn't this about >6 channel support in EAC3 encoder?
Nope, is just quality comparation between 5.1 AC3 and EAC3 by ffmpeg.

Seems than ffmpeg only uses eac3 frames type 0 (eac3 independent, for that the bitrate is limited to 6144 Kb/s at 48 KHz, with 256 samples per frame with a max size of 4096 bytes).

It not use dependent frames, for that is limited to 5.1 and others (more bitrate, channels and programs).

And it not use frames type 2 (AC3 encoded) for that it can't be used for BD tracks than need embedded AC3.

The question is if the EAC3 encoder have better quality at same size than AC3 like Dolby claim in their encoder.

microchip8
7th September 2021, 12:48
Nope, is just quality comparation between 5.1 AC3 and EAC3 by ffmpeg.

Seems than ffmpeg only uses eac3 frames type 0 (eac3 independent, for that the bitrate is limited to 6144 Kb/s at 48 KHz, with 256 samples per frame with a max size of 4096 bytes).

It not use dependent frames, for that is limited to 5.1 and others (more bitrate, channels and programs).

And it not use frames type 2 (AC3 encoded) for that it can't be used for BD tracks than need embedded AC3.

The question is if the EAC3 encoder have better quality at same size than AC3 like Dolby claim in their encoder.

Looking at the code, ffmpeg's E-AC-3 encoder has Adaptive Hybrid Transform, Spectral Extension and Transient Pre-noise processing implemented. So I assume it has a benefit over AC-3 but at pretty low bitrates

Richard1485
7th September 2021, 15:12
Yeah, to hear much improvement with E-AC-3, you have to set the bitrate lower. In my view, it's not worth sacrificing AC-3's greater compatibility for a modest reduction in file-size and/or (at sane bitrates) a negligible increase in quality, especially given that ffmpeg's AC-3 encoder is so good these days. If you're interested only in playback via PC, you might as well use AAC instead.

bokeron2020
7th September 2021, 18:50
Too high. You need to go lower.

DD vs DDP is roughly anagulous to AAC & HE-AAC, and like all lossy codecs, comparisons are useless if the bitrate is too high.

Going lower than 192 with ffmpeg's implementation is downright awful for DD or DDP.

bokeron2020
7th September 2021, 19:06
Yeah, to hear much improvement with E-AC-3, you have to set the bitrate lower. In my view, it's not worth sacrificing AC-3's greater compatibility for a modest reduction in file-size and/or (at sane bitrates) a negligible increase in quality, especially given that ffmpeg's AC-3 encoder is so good these days. If you're interested only in playback via PC, you might as well use AAC instead.

According to the lonely EBU test of old, improvements should be noticeable at 256 and higher, too. But apparently not if using ffmpeg's implementation.
I suppose a commercial encoder would fare a lot better at any given bitrate.

AAC isn't well supported for multichannel audio in hardware players/decoders. I'm aiming for such compatibility... and I don't know where the market will go regarding AAC but Dolby/DTS are still dominant and churning out AC3/DTS centered tecghnologies.

bokeron2020
7th September 2021, 19:11
Looking at the code, ffmpeg's E-AC-3 encoder has Adaptive Hybrid Transform, Spectral Extension and Transient Pre-noise processing implemented. So I assume it has a benefit over AC-3 but at pretty low bitrates

Applying phase cancellation shows some minor differences at any useable bitrate. For 5.1 channels, going lower than 192kbps for anything but voice ends in a poltergeist-like event.

bokeron2020
7th September 2021, 19:22
Isn't this about >6 channel support in EAC3 encoder?

If you mean EAC3 allows more than 5.1 channel... then that may be the only difference with AC3 in ffmpeg.

What I'm experiencing and testing is ffmpeg's EAC3 performing at roughly the same level of quality than AC3... and that should not be the case. EBU 2007 tests show DD+ being superior.

So I'm here trying to find confirmation to my findings so I can be sure I am really hearing what I think I hear, ie, no difference.

microchip8
7th September 2021, 19:23
Applying phase cancellation shows some minor differences at any useable bitrate. For 5.1 channels, going lower than 192kbps for anything but voice ends in a poltergeist-like event.

You haven't told us anything about the equipment your using for the test and how well your ears can spot a difference.

bokeron2020
7th September 2021, 20:25
You haven't told us anything about the equipment your using for the test and how well your ears can spot a difference.

Equipment:
- Beyerdynamic DT-1770 Pro headphones
- Sabaj D5 DAC
- foobar2000 ABX plugin
- Audacity for phase cancellation check.
- My ears: 10-16800Hz range @10dB, can ABX FLAC/Stereo MP3 @-V1 or CBR 256 / AC3 5.1 @ 640 from 448 (not easily, I mean, I can but I have to focus heavily on artifacts)

Phase cancellation tests are objective. Subjectively speaking the objective results show no big difference.
So my ABX tests and phase cancellation seem to point the same way.

microchip8
7th September 2021, 20:29
Equipment:
- Beyerdynamic DT-1770 Pro headphones
- Sabaj D5 DAC
- foobar2000 ABX plugin
- Audacity for phase cancellation check.
- My ears: 10-16800Hz range @10dB, can ABX FLAC/Stereo MP3 @-V1 or CBR 256 / AC3 5.1 @ 640 from 448

Phase cancellation tests are objective. Subjectively speaking the objective results show no big difference.

OK

IIRC, AC-3 and E-AC-3 are not meant to be used below 192 kbps for 5.1 audio. That's meant for AC-4 according to a few things I read about it.

You can try 224 or 320 kbps for both AC-3 and E-AC-3 @ 5.1. See if you spot something

tebasuna51
7th September 2021, 20:59
I've tested 192 kbpps - 256kbps - 384kbps
The old AC3 encoder Sonic Foundry apply by default for 5.1, 48 KHz:

Bitrate Bandwidth
Kb/s KHz
------- ---------
224 9.05
256 12.42
320 15.80
384 18.05
448 20.30

192 can't be used for 5.1
I can't recommend less than 384 Kb/s for 5.1

bokeron2020
7th September 2021, 21:40
OK

IIRC, AC-3 and E-AC-3 are not meant to be used below 192 kbps for 5.1 audio. That's meant for AC-4 according to a few things I read about it.

You can try 224 or 320 kbps for both AC-3 and E-AC-3 @ 5.1. See if you spot something

I did it.
As tebasuna51 just quoted, I tested 192, 256 and 384 kbps.
My results show that, at every bitrate, EAC3 ≈ AC3 quality-wise.


The old AC3 encoder Sonic Foundry apply by default for 5.1, 48 KHz:
Bitrate Bandwidth
Kb/s KHz
------- ---------
224 9.05
256 12.42
320 15.80
384 18.05
448 20.30
192 can't be used for 5.1
I can't recommend less than 384 Kb/s for 5.1
From https://developer.dolby.com/technology/dolby-audio/dolby-digital-plus/
5.1-ch audio in Dolby Digital Plus is typically encoded at bitrates between 192-256 kbps
In my tests with ffmpeg's encoders 192kbps sounds really bad. Apparently one difference with Dolby licensed encoders is they cut off high frequencies as you've shown, while ffmpeg doesn't do it and/or can be modified with -cutoff.

I tested with and without cutoff, though. Same settings, similar results from AC3 or EAC3.
Therefore I can only conclude that while ffmpeg's AC3 may be close or equal to commercial encoders, their EAC3 is way behind.


I don't have the knowledge to understand ffmpeg's source code so it would be great if someone who can could explain it or disprove it... and, complementary to this, someone who knows what the stance of the developers is about this codec could shed some light on why is apparently subpar yet.

Richard1485
7th September 2021, 22:25
According to the lonely EBU test of old, improvements should be noticeable at 256 and higher, too. But apparently not if using ffmpeg's implementation.
I suppose a commercial encoder would fare a lot better at any given bitrate.

Yeah, the official Dolby encoder still beats ffmpeg's AC-3 encoder, but the latter has been in development for so long now that the difference in quality isn't worth worrying about, whereas the E-AC-3 encoder still lags behind the commercial equivalent.

AAC isn't well supported for multichannel audio in hardware players/decoders. I'm aiming for such compatibility... and I don't know where the market will go regarding AAC but Dolby/DTS are still dominant and churning out AC3/DTS centered technologies.

Exactly, which is why I mentioned AAC only in the context of playback via PC. For compatibility with stand-alone players, AC-3 is the way to go: 5.1@640kbps sounds so good that switching to E-AC3 isn't worth the modest space saving or quality improvement. AFAIK, ffmpeg's E-AC-3 encoder still doesn't produce BD-compatible encodes.

nevcairiel
7th September 2021, 22:46
The main reason E-AC3 was added to FFmpeg was that it allows flexible bitrate values (including a higher maximum), and not just the pre-defined presets AC3 uses. New E-AC3 coding tools are not actually implemented, unless required by the bitstream.
Due to some coding improvements its minimally better then AC3 at any given bitrate, but probably not even measurable.

bokeron2020
8th September 2021, 00:21
The main reason E-AC3 was added to FFmpeg was that it allows flexible bitrate values (including a higher maximum), and not just the pre-defined presets AC3 uses. New E-AC3 coding tools are not actually implemented, unless required by the bitstream.
Due to some coding improvements its minimally better then AC3 at any given bitrate, but probably not even measurable.

I guess that answers the question conclusively. Thank you. :)

I suppose there are no plans to improve it as developers seem to have other priorities/interests. I'll use what's available then.

Blue_MiSfit
8th September 2021, 01:02
Dolby's official E-AC3 encoders are dramatically better than what's available in ffmpeg, and in addition to being better quality the Dolby tooling (e.g. Dolby Encoding Engine) can properly analyze and set DRC and dialnorm metadata. They also of course support the 7.1 and Atmos / JOC flavors of E-AC3.

The AC3 and E-AC3 encoders in ffmpeg are fine for most folks use cases (mostly getting S/PDIF compatibility for 5.1 audio), but they definitely don't represent the bitstream capabilities :)

bokeron2020
8th September 2021, 03:37
Dolby's official E-AC3 encoders are dramatically better than what's available in ffmpeg, and in addition to being better quality the Dolby tooling (e.g. Dolby Encoding Engine) can properly analyze and set DRC and dialnorm metadata. They also of course support the 7.1 and Atmos / JOC flavors of E-AC3.

The AC3 and E-AC3 encoders in ffmpeg are fine for most folks use cases (mostly getting S/PDIF compatibility for 5.1 audio), but they definitely don't represent the bitstream capabilities :)

That was out of the question. What was being compared was ffmpeg AC3 vs. ffmpeg EAC3.

I would like to have a Dolby Encoder to test... but we hobbyists can't play with big boy's toys. :D

Blue_MiSfit
8th September 2021, 07:46
Of course, just stating for anyone jumping to the end of the thread :)

microchip8
8th September 2021, 15:00
Well, if your claims are true, then we should avoid encoding at very low bitrates for both AC-3 and E-AC-3. I personally encode all my Blu-rays with E-AC-3 5.1 @ 960 kbps and can't tell the difference between it and the source lossless DTS HD MA

bokeron2020
8th September 2021, 20:28
Well, if your claims are true, then we should avoid encoding at very low bitrates for both AC-3 and E-AC-3. I personally encode all my Blu-rays with E-AC-3 5.1 @ 960 kbps and can't tell the difference between it and the source lossless DTS HD MA

I'm not really claiming anything.
I was interested in getting opinions on the results I have, wether to confirm or disprove them, and also to expose it to people with the knowledge to explain what's going on with ffmpeg's AC3/EAC3.

At 960 I doubt we'd hear any difference even comparing to the proverbial choir of angels :D

FWIW, I guess 640 is more than enough for 5.1 ffmpeg's AC3/EAC3

j7n
8th September 2021, 22:48
Or is there really no quality difference between EAC3 and AC3 for the same bitrate/channels even using professional codecs and comparing between them?

I would like to have a Dolby Encoder to test...

The Dolby encoder degrades more gracefully at extremely low bitrates than ffmpeg. 5.1 music at 256 kbit/s is unlistenable with ffmpeg. But those bitrates should not be used. I would prefer AC-3 for maximum compatibility with 2 or 6 channels. Audio size is easy to handle relative to video, with modern internet connections or storage.

EC3 has slightly more bandwidth than AC3 at the same bitrate. I struggle to hear a significant difference with normal music, apart from artificial killer samples with sharp impulses such as "Everything Is Green" where ffmpeg is more smeared. But the reason for that is mainly my worn ears.

Tools with the Dolby encoder are frustrating to use. They either require split channels, encode only one file at a time, or read from directshow with random delay and limited maximum file size, or the GUI is bloated and awkward, may require mapping of input channels. There is a plugin for Sound Forge, it can take floating point input, but seems to work only with stereo.

j7n.sytes.net/misc/ac3samples/

bokeron2020
9th September 2021, 01:22
The Dolby encoder degrades more gracefully at extremely low bitrates than ffmpeg. 5.1 music at 256 kbit/s is unlistenable with ffmpeg. But those bitrates should not be used. I would prefer AC-3 for maximum compatibility with 2 or 6 channels. Audio size is easy to handle relative to video, with modern internet connections or storage.

EC3 has slightly more bandwidth than AC3 at the same bitrate. I struggle to hear a significant difference with normal music, apart from artificial killer samples with sharp impulses such as "Everything Is Green" where ffmpeg is more smeared. But the reason for that is mainly my worn ears.

Tools with the Dolby encoder are frustrating to use. They either require split channels, encode only one file at a time, or read from directshow with random delay and limited maximum file size, or the GUI is bloated and awkward, may require mapping of input channels. There is a plugin for Sound Forge, it can take floating point input, but seems to work only with stereo.

j7n.sytes.net/misc/ac3samples/

I just did a quick test using your samples and encoding your wav to Ac3 so I can compare with current ffmpeg version, the one I used for my own tests. I've marked those as *myf*

Equinox in stereo:

equinoxf_pro128.Ac3 - ABX 10/10
equinoxf_pro128.Ec3 - ABX 10/10
equinoxf_myf128.Ec3 - ABX 10/10

pro-Ec3 has a slight edge over pro-Ac3, though.




equinoxf_pro192.Ac3 - ABX 8/10
equinoxf_pro192.Ec3 - ABX 7/10
equinoxf_myf192.Ac3 - ABX 10/10

pro-Ec3 still have a slight edge over pro-Ac3




equinoxf_pro256.Ac3 - ABX 6/10
equinoxf_pro256.Ec3 - ABX 3/10
equinoxf_myf256.Ac3 - ABX 7/10

pro-Ac3 is almost transparent to me but I still can tell it apart if I focus on very specific sounds.
pro-Ec3 is basically transparent to me here... I think I still hear something different somewhere but couldn't pinpoint it well enough so I might be simply wrong.




equinoxf_myf384.Ac3 - ABX 5/10

ffmpg's Ac3 @384 is apparently transparent but I think I could find something to focus on if I took more time to test.



Sooo... pro-Ec3 > pro-AC3 > ffmpeg AC3 ... quite what everybody expected, I suppose :D
I'll try 5.1 when I have time (If I have time)


PS: Did I read something about Dolby Encoding Engine being used via CLI? I think that would speed things up when automating via scripting even if you need to split 5.1 tracks to 6 wav files. Once your script is working the process would be transparent to you.

Blue_MiSfit
9th September 2021, 08:45
Tools with the Dolby encoder are frustrating to use. They either require split channels, encode only one file at a time, or read from directshow with random delay and limited maximum file size, or the GUI is bloated and awkward, may require mapping of input channels. There is a plugin for Sound Forge, it can take floating point input, but seems to work only with stereo.

j7n.sytes.net/misc/ac3samples/

Dolby Encoding Engine is a very flexible general purpose CLI application that also has a REST API. It accepts lots of different input file formats (I often feed interleaved RF64 pcm_s24le WAV files)

Etroxamin
9th September 2021, 09:13
dolby e-ac3 encoder will sound better in most cases i guess, unless a bitrate is used where it eventually won't make sense to do lossy encoding at all.

on the other side, there might be a bitrate, giving ffmepg a try over dolbys settings:

Eventually you may listened to music, or sound in lossless high quality. A day later you istened to the same audio in lossy, for whatever reason and without even much hearing you can actually say after a few seconds, that this sounds horrible to you in some way. While doing comparisons directly, the difference might not be so obviously.

This may sounds very subjective, but you can't just hear music, you can also feel it and much like this seems obviously for bass sounds (as we all know how it feels to stand near to huge speaker) there are also high frequencies stimulating the brain, even if we can't hear them with our ears, this is known known as "hypersonic effect".

Consdering this, at a certainly high bitrate, like 150-200kbps per channel and more, ffmepg may not sound better, but feels better :)

but that's just theory of course, i actually don't know if the dolby encoder will put more bits into high frequencies, if a lvl of quality is more or less saved by a certain bitrate already - could be the case, or not and the dolby encoder starts to waste bitrate at some point.

Unfortunately i cant say much about ac3 vs eac3, only that you may not always should compare directly, but make a delayed test, and choose by your feeling.

SquallMX
13th September 2021, 16:40
That was out of the question. What was being compared was ffmpeg AC3 vs. ffmpeg EAC3.

I would like to have a Dolby Encoder to test... but we hobbyists can't play with big boy's toys. :D

Old versions of Adobe Audition had an official EAC3 encoder, is way better than the one at FFMPEG, but not perfect, at 256 Kbps it created some ringing on sources with 15.7 Khz tones (The line frequency of old NTSC TVs, very common on dubs), I had to manually lowpass such files in order to avoid it.

Balling
14th September 2021, 12:54
The main reason E-AC3 was added to FFmpeg was that it allows flexible bitrate values (including a higher maximum), and not just the pre-defined presets AC3 uses. New E-AC3 coding tools are not actually implemented, unless required by the bitstream.
Due to some coding improvements its minimally better then AC3 at any given bitrate, but probably not even measurable.

That is true but higher bitrates were broken for a very long time until I investigated and mkver fixed it. That was like an one liner fix. https://trac.ffmpeg.org/ticket/8513

AFAIK, there is no limit on maximum bitrate :)

Balling
14th September 2021, 12:57
Eventually you may listened to music, or sound in lossless high quality. A day later you istened to the same audio in lossy, for whatever reason and without even much hearing you can actually say after a few seconds, that this sounds horrible to you in some way. While doing comparisons directly, the difference might not be so obviously.



Actually, ffmpeg EAC3/AC3 decoder has DRC turned on by default. You can turn it off, though Dolby recommends using it.

Balling
14th September 2021, 13:01
Dolby's official E-AC3 encoders are dramatically better than what's available in ffmpeg, and in addition to being better quality the Dolby tooling (e.g. Dolby Encoding Engine) can properly analyze and set DRC and dialnorm metadata. They also of course support the 7.1 and Atmos / JOC flavors of E-AC3.

The AC3 and E-AC3 encoders in ffmpeg are fine for most folks use cases (mostly getting S/PDIF compatibility for 5.1 audio), but they definitely don't represent the bitstream capabilities :)

DRC can be decoded by ffmpeg, by default. TrueHD decoder is not supporting DRC, that is one of its key limitations (besides decoding 7.1 full 24 bit content that is somehow not lossless). Now encoders are not supporting DRC, true. https://patchwork.ffmpeg.org/project/ffmpeg/patch/20200201193443.22419-1-rcombs@rcombs.me/

tormento
31st January 2024, 00:55
Has there been any improvement in ffmpeg DDP implementation?

I have a 2.1 (L,R,LFE) DTS audio file that ffmpeg only could encode in 2.1 keeping proper channel configuration.

Balling
24th February 2024, 06:31
Has there been any improvement in ffmpeg DDP implementation?

I have a 2.1 (L,R,LFE) DTS audio file that ffmpeg only could encode in 2.1 keeping proper channel configuration.

Can you clarify your issue?

tormento
25th February 2024, 10:16
Can you clarify your issue?


I always use DEE but it lacks some channel configurations, such as 2.1 and 6.1.

The last time I used ffmpeg it went up to 5.1 and the quality wasn’t optimal.

Hence my question about ffmpeg DDP improvement, if any.

richardpl
25th February 2024, 11:56
There is many improvements, since last your donations.