Log in

View Full Version : Converting problematic AC3 5.1 to MP3


bollemanneke
1st September 2016, 16:12
Hello people. It feels so nostalgic to post here again... Anyway...

I hope this particular issue hasn't been discused here yet. This is a fairly unique problem so hopefully someone will be able to help me out.

I am currently trying to convert the AC3 5.1 files of The Hobbit DVDs to stereo MP3. However, the AC3s are mixed in sucha way that playing them/converting them in/to stereo results in terrible music distortion. I'm told it's because the first film's audio, for example, needs an 8DB reduction to avoid clipping, apparently the sound mix was recorded too loudly.

I usually do these things with DVD Audio Extractor, but it can't handle these files either. I let AutoGK give it a shot, but those decoders didn't do the proper job either.

So, my question is: Is there an easy-to-use programme that can convert these files for me and, very importantly, that will automatically determine the distortion problem and how to fix it? I have no idea what they were playing at in the studio when they put these DVDs on the market, but the sound is absolutely horrible in stereo.

sneaker_ger
1st September 2016, 16:34
eac3to will detect and adjust for clipping in a 2nd pass if necessary.
So:
eac3to.exe input.ac3 output.wav -down2

Then convert output.wav to mp3 with a different tool like lame cli. Maybe so. else can give you a suggestion for a GUI that automates the process...

bollemanneke
1st September 2016, 16:44
Thanks a lot , I'll give it a shot.

bollemanneke
1st September 2016, 17:17
Okay, I just gave it a go: eac3to applied a -0.65dB gain. The result is better but still not perfect.

hello_hello
1st September 2016, 18:51
Dropping the LFE channel might help, but thinking about it, did you downmix to Dolby Pro logic stereo? I'm pretty sure AutoGK does it that way, I'm not sure which method eac3to uses by default, MeGUI lets you choose, as does foobar2000. If you're not sure, maybe start by taking Prologic downmixing out of the equation to see if a standard stereo downmix sounds better.

MGUI's audio encoder configuration is pretty self explanatory. Load an audio file, add the job to the queue and run it. I'm fairly sure there's no way the downmixing method it uses can cause clipping. It's all done in 32 bit float (output as 24bit for LAME)
Maybe it's just crappy sounding audio?

I'm fairly sure the Dolby spec says 5.1ch needs a 7.5dB gain reduction when downmixing, but whatever the amount, that's the reduction most programs will be applying. After downmixing they generally peak normalise. If the output wasn't quite similar from one program to the next when using the same encoder, it'd more more disappointing than anything else.

bollemanneke
1st September 2016, 22:45
It's only crappy when you play/convert it to stereo... Also, I tried a stereo conversion with eac3to (why isn't that just a program?), but it didn't work great either. Isn't there a good all-in-one app that can do this? I don't really want to try five different encoders/decoders and use them based on command-promt scripts...

Groucho2004
1st September 2016, 23:05
It's only crappy when you play/convert it to stereo... Also, I tried a stereo conversion with eac3to (why isn't that just a program?), but it didn't work great either. Isn't there a good all-in-one app that can do this? I don't really want to try five different encoders/decoders and use them based on command-promt scripts...
eac3to and also ffmpeg should not introduce clipping when downmixing.
Use DelayCut (http://www.videohelp.com/software/delaycut) to cut a small section of the ac3 that exhibits clipping/distortion after conversion and post it so we can have a look at it.

bollemanneke
1st September 2016, 23:15
Okay, here is a sample:
https://www.sendspace.com/file/patrjf
For those of you wondering, it's the audiodescribed version of the film, for blind/visually impaired people. The distortion in stereo playabck starts at around 00:08, when the rear channels come in and does not affect the centre channel.

Groucho2004
1st September 2016, 23:30
Okay, here is a sample:
https://www.sendspace.com/file/patrjf
For those of you wondering, it's the audiodescribed version of the film, for blind/visually impaired people. The distortion in stereo playabck starts at around 00:08, when the rear channels come in and does not affect the centre channel.
I extracted all channels with "eac3to test.ac3 test.wavs". The center channel is very loud compared to all others. I would use ffmpeg to attenuate the center and then downmix straight to mp3. You can probably do this with one command, look at the ffmpeg documentation or use google.

Edit: Maybe tebasuna51 has a better suggestion, he's very knowledgable with everything related to downmixing.

tebasuna51
2nd September 2016, 01:55
eac3to can do 2 downmix

-downDpl (or -down2)
FL' = FL + 0.7071 x FC + 0.8660 x BL + 0.5000 x BR
FR' = FR + 0.7071 x FC - 0.5000 x BL - 0.8660 x BR

-downStereo
FL' = FL + 0.7071 x FC + BL
FR' = FR + 0.7071 x FC + BR

And with the parameter -mixlfe, mix also the LFE channel:
FL' = ... + 0.7071 x LFE
FR' = ... + 0.7071 x LFE

If there are overflow adding channels apply a negative gain (your -0.65dB gain)

I used -downDpl to make Title1_1.mp3 and -downStereo to make Title1_2.mp3

Also I used AviSynth to make other mix, Title1_3.mp3, without surround channels, because sometimes are in a inapropiate phase and can cause problems:
FL' = 0.9 x FL + 0.7 x FC
FR' = 0.9 x FR + 0.7 x FC

Check if someone is good for you: https://www.sendspace.com/file/59xl5a

Ghitulescu
2nd September 2016, 07:40
I do not know how eac3to internally works, however, it may be that no matter what downmixing algorithm you use you'll end with distorted audio. This is a well-known issue in audio field, so I fairly assume this will happen here too.

I suggest you therefore 2 steps:
*apply a -6dB (to be sure, you may experiment, you loose only 1 bit of resolution) to the source AC3. (eac3to -6dB etc etc)
*do the downmix onto the result (eac3to -down2 etc etc)
*(optional) normalise the audio.(eac3to -normalize etc etc)

MP3 has a lot of issues, why not using DD2.0? Or AAC? Both are better.

bollemanneke
2nd September 2016, 10:45
Hi Tebasuna, thanks for your files.

Title 1:1 sounds fairly good, but not quite perfect.
Title 1:2 sounds horrible, just like what AutoGK and DVD Audio Extractor did.
Title 1:3 sounds perfect! Truly amazing. What do you suggest I do to get such results?

tebasuna51
2nd September 2016, 11:08
I do not know how eac3to internally works,
Just I explain you how work.
I think than madshi follow my sugerences in: http://forum.doom9.org/showthread.php?p=1600695#post1600695

When add the signal channels the samples are in float 64 bits and check the max overflow to apply, if needed at end, to the full file when converted to desired bitdepth (by default 24 int when wav/flac output).

When you see a message like: "eac3to applied a -0.65dB gain"
apply after a Normalize is usseless because the signal have reach the max peak allowed volume.

If you don't see that message you can still apply the normalize, but most the times is not necesary, only if your source have very low voume.

however, it may be that no matter what downmixing algorithm you use you'll end with distorted audio.
The distorted audio can't be by overflow problem, like explained before.

Can be when add signals out of phase. One signal can cancel (or overload) the others depending of frequencies.

Even Dolby never recommend use LFE in downmix for that.

But if Surround channels was generated out of Dolby specs the problem can be when add Front with Surround channels.
For that my option 3.

If Front and Center channels are out of phase we can't do anything to solve the problem, but is not usual.

MP3 has a lot of issues, why not using DD2.0? Or AAC? Both are better.

Of course AAC is better, and AAC stereo is compatible with many players.

But MP3 is more efficient than AC3 2.0, and MP3 CBR can be used with avi container or with players without AAC support.

tebasuna51
2nd September 2016, 12:02
Title 1:3 sounds perfect! Truly amazing. What do you suggest I do to get such results?

Them seems the out of phase problem between Front and Surround channels.

I use AviSynth, if you are a user of AutoGK I suposse you have AviSynth installed (I hope was a version compatible with that).

You can use MeGUI or BeHappy like GUI, more easy BeHappy (download in my signature) if you don't use MeGUI (recomended to replace AutoGK).

You need make a custom_down.avs file (with Notepad for instance) like this (copy and paste):
NicAc3Source("D:\Internet\Title1.ac3")
a = ConvertAudioToFloat()
f = GetChannel(a, 1, 2)
c = GetChannel(a, 3, 3)
MixAudio(f, c, 1.0, 0.7071)
Normalize()
ConvertAudioTo24bit()


Replace "D:\Internet\Title1.ac3" with your source ac3 file.
If is too loud for you, you can add a coeficient to Normalize().
For instance: Normalize(0.8)

- Load (or drag and drop) the custom_down.avs over BeHappy [1] Source
- Select name and encoder (Configure like your preferences) in [4] Destination
- Enqueue
- Go to Queue tab and Start

bollemanneke
2nd September 2016, 12:13
Thanks very much, I will give that a go.

tebasuna51
2nd September 2016, 12:46
To Behappy users.

I added to BeHappy that downmix.
Uncompress and replace the attached file in ...\BeHappy\extensions folder (use last BeHappy version)

Now you can load any file with the recomended decoder in [1] Source

In [3] DSP
- select Donwmix and Configure like Simple (F+C)
- select Normalize and Configure at your desired volume

In [4] Destination select name and encoder like before.

bollemanneke
3rd September 2016, 17:39
Right, final question. I used Audacity to lower the volume of the rear channels, which does the trick. The only problem now is that I can't export the six tracks to stereo MP3. If I use normal export to stereo MP3, only the front channels are exported (even when I mark them as left, right, mono etc), and if I use mix and render, all the channels become one mono channel. What am I missing?

tebasuna51
3rd September 2016, 18:25
Maybe like this:

bollemanneke
3rd September 2016, 18:28
Could you... possibly describe that image? (I'm blind.)

tebasuna51
3rd September 2016, 20:18
When you export 6 channels to 2 (mp3) the advanced mix options window show conected 'Title0 1' (Front Left) with 'Canal 1' (Left) and 'Title0 2' (Front Right) with 'Canal 2' (Right)

Click 'Canal 1' to select
Click 'Title0 3' to mix Center channel in Left (Canal 1)
Click 'Title0 5' to mix Surround Left in Left (Canal 1)

Click 'Canal 1' to unselect
Click 'Canal 2' to select

Click 'Title0 3' to mix Center channel in Right (Canal 2)
Click 'Title0 6' to mix Surround Right in Right (Canal 2)

bollemanneke
4th September 2016, 18:28
Thanks. The mixing worked all right, but the music STILL sounds distorted. Honestly, I have no idea which idiot mixed this surround sound. YOu just can't play it through two speakers.

tebasuna51
4th September 2016, 20:38
Use only:

Click 'Canal 1' to select
Click 'Title0 3' to mix Center channel in Left (Canal 1)

Click 'Canal 1' to unselect
Click 'Canal 2' to select

Click 'Title0 3' to mix Center channel in Right (Canal 2)

without mix the out of phase surround channels.

Ghitulescu
5th September 2016, 08:50
Thanks. The mixing worked all right, but the music STILL sounds distorted. Honestly, I have no idea which idiot mixed this surround sound. YOu just can't play it through two speakers.

I am not sure if you said or not whether the original soundtrack was (or sounded) distorted. Because if it already sounds distorted, one needs to use a sort of declipping algorithms before, and of course reduce the loudness/volume by a number of dB, say 6 (that means 1 bit less of resolution, and it's easy to be done in any software).

Have you tried my suggestion to lower the volume by 6dB BEFORE downmixing? Yes, I know what tebasuna51 said...

tebasuna51
5th September 2016, 11:16
@Ghitulescu
Sometimes the problem is clip audio like you say, but I downloaded the source and analyzed each channel without see any clip at all.
Even the 3 downmixed samples I upload don't have clips at any point.

When I downmix convert before the samples to float values than support volumes greater than 0 dB without problems, after mix the Normalize amplify or attenuate to selected volume without clip.
Then lower the volume before the downmix is usseless if you use float values, like eac3to and BeHappy do (check the avs).

Using Audacity, than use always float samples, the problem can appear at final downmix. The correct procedure can be:
- Lower the volume of center channel -3 dB (0.7071), to obtain the same acustic power than original when mixed in 2 channels.
- Mix the center channel over the front left and over the front right.
- Check for overflows and normalize, if needed, the front channels.
- Export only the front channels to mp3.

Is more easy use BeHappy to do all the job.