View Full Version : Converting AC3 5.1 to stereo with volume adjusting
alexVS
11th January 2020, 22:43
Long time ago I converted AC3 5.1 to stereo using Graphedit and AC3filter. I could adjust sound so, that dialog and central channel become louder. Like in picture.
But now WAVDEST.AX dated 1998 year old, It's kind of scary to install codecs 20+ years old. And AC3filter is not required in system, i use LAV decoder.
How can I fast transcode audio 5.1 to stereo using something modern, fast, may be portable. I tried BeHappy, but it's difficult, and I can't find right coefficients for avisynth Mixaudio and Mergechannels.
I just need to convert AC3 5.1 to WAV Stereo, boosting central channel with speech, and lowering special effects, that are usually in SL, SR channel. And may be mute LFE sounds. And speed matters, because demuxing all to 6 wav, editing volume in soundforge , encoding and muxing back is very time consuming.
Can ffmpeg or eac3to help with it? or something other? Help, please!
manolito
12th January 2020, 04:18
If you use LAV Audio decoder then you can enable its mixing feature. Set the mixing target to Stereo, you can control the levels for the center channel, surround channels and LFE.
The other option I use all the time lets AviSynth do the work. Use this function: (by Tebasuna)
Function Dmix6Stereo(clip a)
{
flr = GetChannel(a, 1, 2)
fcc = GetChannel(a, 3, 3)
lrc = MixAudio(flr, fcc, 0.3694, 0.2612)
blr = GetChannel(a, 5, 6)
return MixAudio(lrc, blr, 1.0, 0.3694)
}
and adjust the coefficients in bold to your liking (LFE is not used by default).
If you want the LFE channel in the downmix use this function:
Function Dmix6StereoLfe(clip a)
{
flr = GetChannel(a, 1, 2)
fcc = GetChannel(a, 3)
lfe = GetChannel(a, 4)
lfc = MixAudio(fcc, lfe, 0.2071, 0.2071)
mix = MergeChannels(lfc, lfc)
lrc = MixAudio(flr, mix, 0.2929, 1.0)
blr = GetChannel(a, 5, 6)
return MixAudio(lrc, blr, 1.0, 0.2929)
}
tebasuna51
12th January 2020, 11:31
Long time ago I converted AC3 5.1 to stereo using Graphedit and AC3filter. I could adjust sound so, that dialog and central channel become louder. Like in picture...
In your picture seems the Center channel at high volume and low volume for surround channels. Maybe you can try a avs mix like:
Function Dmix6Stereo(clip a) {
flr = GetChannel(a, 1, 2)
fcc = GetChannel(a, 3, 3)
lrc = MixAudio(flr, fcc, 0.4, 0.4)
blr = GetChannel(a, 5, 6)
return MixAudio(lrc, blr, 1.0, 0.2)
}
- The 3 coeficients must sum 1.0 to avoid clip.
- Like the C channel is present in L and R output channels the volume is equivalent to 0.8
You can use also ffmpeg with:
ffmpeg -drc_scale 0 -i "input.ac3" -af "pan=stereo|FL < .4FL + .4FC + .2SL|FR < .4FR + .4FC + .2SR" -acodec pcm_s24le "output.wav"
or recode to AAC, AC3, ...
EDIT: if you have the UsEac3to GUI with ffmpeg and qaac:
Richard1485
12th January 2020, 21:47
Function Dmix6Stereo(clip a)
{
flr = GetChannel(a, 1, 2)
fcc = GetChannel(a, 3, 3)
lrc = MixAudio(flr, fcc, 0.3694, 0.2612)
blr = GetChannel(a, 5, 6)
return MixAudio(lrc, blr, 1.0, 0.3694)
}
You can use also ffmpeg with:
ffmpeg -drc_scale 0 -i "input.ac3" -af "pan=stereo|FL < .4FL + .4FC + .2SL|FR < .4FR + .4FC + .2SR" -acodec pcm_s24le "output.wav"
So, to make the first downmix that manolito posted, it's like this in ffmpeg:
ffmpeg -drc_scale 0 -i "input.ac3" -af "pan=stereo|FL < .3694FL + .3694FC + .2612SL|FR < .3694FR + .3694FC + .2612SR" -acodec pcm_s24le "output.wav"
Is that right?
tebasuna51
13th January 2020, 03:50
Nope:
MixAudio(flr, fcc, 0.3694, 0.2612)
MixAudio(lrc, blr, 1.0, 0.3694)
ffmpeg -drc_scale 0 -i "input.ac3" -af "pan=stereo|FL < .3694FL + .2612FC + .3694SL|FR < .3694FR + .2612FC + .3694SR" -acodec pcm_s24le "output.wav"
Fluffbutt
13th January 2020, 11:53
I use this with success
D:\Downloads\ffmpeg.exe -hide_banner -i %1 -threads 8 -map 0:a:0 -f mp3 -acodec mp3 -b:a 128k -ac 2 -af pan=stereo:FL=0.25*FL+FC+0.6*LFE:FR=0.25*FR+FC+0.6*LFE -af "volume=0.01dB" "%~dp1%~n1.mp3"
The volume = numbers comes from
D:\Downloads\ffmpeg.exe -hide_banner -i %1 -threads 8 -af volumedetect -f null -
pause
Just copy the number af6ter "max_volume", without the minus sign... max_volume: -3.2db becomes 3.2 in that top cmd file (nb, they are both cmd files that you drag and drop the film or audo mka file onto.
My standard procedure:
mux out the audio to mka with mkvtoolnix.
drop xyz.mka onto the second cmd (my first file used)
edit the top cmd line to have the right number dB, save file
drop mka onto that cmd file
remux with mkvtoolnix, delete original audio, select my new mp3.
Of course, edit the bitrate to suit yourself.
And... anyone know how to go through the ffmpeg output and auto select that "3.2" number then send it to the second file (or down the line in one cmd file)?
Everything I've tried (from the various techy forums) has not worked.
(^ that's not a hijack, it'll benefit us all if I can find it to make it one drag and drop job.
alexVS
13th January 2020, 17:36
Thanks a lot! This works wonderfull:
ffmpeg -drc_scale 0 -i "sound.ac3" -af "pan=stereo|FL < .4FL + .4FC + .2SL|FR < .4FR + .4FC + .2SR" -acodec ac3 -b:a 192k "sound_output.ac3"
I'm not sure about avisynth. Must I open AC3 with DirectShowSource or NicAC3Source?
And DRC paramerer must be 0 or 1?
LoadPlugin("D:\program files\avisynth 2.5\plugins\NicAudio.dll")
Function Dmix6Stereo(clip a)
{
flr = GetChannel(a, 1, 2)
fcc = GetChannel(a, 3, 3)
lrc = MixAudio(flr, fcc, 0.4, 0.4)
blr = GetChannel(a, 5, 6)
return MixAudio(lrc, blr, 1.0, 0.2)
}
a = NicAC3Source("sound.ac3", DRC=1)
a1 = ConvertAudioToFloat(a) # Not sure if I need this line and what this line does
Dmix6Stereo(a1)
#Convertaudioto16() # not needed to encode to ac3/aac
Richard1485
13th January 2020, 17:55
Nope:
Thanks for the correction! I muddled up the order of the coefficients.
tebasuna51
13th January 2020, 23:11
I'm not sure about avisynth.
Better use ffmpeg.
Must I open AC3 with DirectShowSource or NicAC3Source?
Never use DirectShowSource, NicAC3Source is Ok (also ffms2 or L-SMASH)
And DRC paramerer must be 0 or 1?
Use the default (0) like with ffmpeg (-drc_scale 0)
The NicAC3Source (or FFAudioSource, or LWLibavAudioSource) output is already float (audio samples are 32 bit float), ConvertAudioToFloat do nothing.
vBulletin® v3.8.11, Copyright ©2000-2026, vBulletin Solutions Inc.