Welcome to Doom9's Forum, THE in-place to be for everyone interested in DVD conversion.

Before you start posting please read the forum rules. By posting to this forum you agree to abide by the rules.

 

Go Back   Doom9's Forum > Video Encoding > MPEG-4 Encoder GUIs

Reply
 
Thread Tools Search this Thread Display Modes
Old 3rd April 2018, 17:50   #1  |  Link
doomleox999
Registered User
 
Join Date: Nov 2015
Posts: 81
6 channels to Stereo

Hi everyone, first of all english is not my first language, sorry for any mistakes I make.

When I encode a 6ch audio to stereo with MeGUI I use this setting:



The final result is not as loud as the original audio, now, if I extract the audio track from the file and encode it with ffmpeg (-i sixchannels.aac -ac 2 -ab 128k stereo.aac something like that) the result is amazing! It's almost indistinguible from the original.

I'm no expert, so I'm not sure if I'm right, but I feel that ffmpeg mixes the 6 channels and MeGUI only takes 2 out of the 6. Again, I'm not sure if that's right but that's the impression I get.

Am I right? Am I wrong? Is it possible to use ffmpeg WITH MeGUI (to save time) or tell MeGUI to "mix the 6 channels into stereo"?

Thanks in advance!
doomleox999 is offline   Reply With Quote
Old 3rd April 2018, 21:50   #2  |  Link
tebasuna51
Moderator
 
tebasuna51's Avatar
 
Join Date: Feb 2005
Location: Spain
Posts: 6,890
Quote:
Originally Posted by doomleox999 View Post
The final result is not as loud as the original audio
Of course with 2 speakers we can't obtain the same volume than with 6 speakers.

Quote:
if I extract the audio track from the file and encode it with ffmpeg (-i sixchannels.aac -ac 2 -ab 128k stereo.aac something like that) the result is amazing! It's almost indistinguible from the original.
Then use ffmpeg instead MeGUI. No problem.

Quote:
but I feel that ffmpeg mixes the 6 channels and MeGUI only takes 2 out of the 6. Again, I'm not sure if that's right but that's the impression I get.
Nope, MeGUI (AviSynth) mix the 6 channels an normalize to obtain the max volume without distort.

Quote:
Is it possible to use ffmpeg WITH MeGUI (to save time)
To save time use ffmpeg out of MeGUI, you don't need AviSynth for your conversion.
__________________
BeHappy, AviSynth audio transcoder.
tebasuna51 is offline   Reply With Quote
Old 4th April 2018, 04:00   #3  |  Link
hello_hello
Registered User
 
Join Date: Mar 2011
Posts: 4,823
If you check the log file you'll find the script MeGUI uses for downmixing the audio. It reduces the volume to prevent clipping when the channels are combined, followed by Normalize() to increase the peaks to maximum after downmixing (assuming the Normaize option is checked).

Maybe ffmpeg doesn't prevent clipping by default, and likewise when you playback 5.1ch audio being downmixed to stereo, the volume isn't being reduced to prevent clipping either, so they sound the same.
hello_hello is offline   Reply With Quote
Old 4th April 2018, 04:49   #4  |  Link
doomleox999
Registered User
 
Join Date: Nov 2015
Posts: 81
Quote:
Originally Posted by hello_hello View Post
If you check the log file you'll find the script MeGUI uses for downmixing the audio.
Code:
---[Information] Audio
--[Information] [04/04/18 00:36:34] Trying to open the file with LWLibavAudioSource()
--[Information] [04/04/18 00:38:03] Successfully opened the file with LWLibavAudioSource()
-[NoImage] ClearAutoloadDirs()
-[NoImage] AddAutoloadDir("C:\Users\USER\MeGUI\tools\avs\plugins")
-[NoImage] LoadPlugin("C:\Users\USER\MeGUI\tools\lsmash\LSMASHSource.dll")
-[NoImage] LWLibavAudioSource("C:\Users\USER\Desktop\MeGUI Output\AUDIO.aac")
-[NoImage] # detected channels: 6
-[NoImage] # detected channel positions: 3/2/0.1
-[NoImage] LoadPlugin("C:\Users\USER\MeGUI\tools\avisynth_plugin\AudioLimiter.dll")
-[NoImage] c6_stereo(ConvertAudioToFloat(last))
-[NoImage] Normalize()
-[NoImage] return last
-[NoImage] # 5.1 Channels L,R,C,LFE,SL,SR -> stereo + LFE
-[NoImage] function c6_stereo(clip a)
-[NoImage]   {
-[NoImage]      fl = GetChannel(a, 1)
-[NoImage]      fr = GetChannel(a, 2)
-[NoImage]      fc = GetChannel(a, 3)
-[NoImage]      lf = GetChannel(a, 4)
-[NoImage]      sl = GetChannel(a, 5)
-[NoImage]      sr = GetChannel(a, 6)
-[NoImage]      fl_sl = MixAudio(fl, sl, 0.2929, 0.2929)
-[NoImage]      fr_sr = MixAudio(fr, sr, 0.2929, 0.2929)
-[NoImage]      fc_lf = MixAudio(fc, lf, 0.2071, 0.2071)
-[NoImage]      l = MixAudio(fl_sl, fc_lf, 1.0, 1.0)
-[NoImage]      r = MixAudio(fr_sr, fc_lf, 1.0, 1.0)
-[NoImage]      return MergeChannels(l, r)
-[NoImage]   }
-[NoImage] # 5 Channels L,R,C,SL,SR or L,R,LFE,SL,SR-> Stereo
-[NoImage] function c5_stereo(clip a)
-[NoImage]   {
-[NoImage]      fl = GetChannel(a, 1)
-[NoImage]      fr = GetChannel(a, 2)
-[NoImage]      fc = GetChannel(a, 3)
-[NoImage]      sl = GetChannel(a, 4)
-[NoImage]      sr = GetChannel(a, 5)
-[NoImage]      fl_sl = MixAudio(fl, sl, 0.3694, 0.3694)
-[NoImage]      fr_sr = MixAudio(fr, sr, 0.3694, 0.3694)
-[NoImage]      l = MixAudio(fl_sl, fc, 1.0, 0.2612)
-[NoImage]      r = MixAudio(fr_sr, fc, 1.0, 0.2612)
-[NoImage]      return MergeChannels(l, r)
-[NoImage]   }
-[NoImage] # 5 Channels L,R,C,LFE,S -> Stereo
-[NoImage] function c52_stereo(clip a)
-[NoImage]   {
-[NoImage]      fl = GetChannel(a, 1)
-[NoImage]      fr = GetChannel(a, 2)
-[NoImage]      fc = GetChannel(a, 3)
-[NoImage]      lf = GetChannel(a, 4)
-[NoImage]      bc = GetChannel(a, 5)
-[NoImage]      fl_bc = MixAudio(fl, bc, 0.3205, 0.2265)
-[NoImage]      fr_bc = MixAudio(fr, bc, 0.3205, 0.2265)
-[NoImage]      fc_lf = MixAudio(fc, lf, 0.2265, 0.2265)
-[NoImage]      l = MixAudio(fl_bc, fc_lf, 1.0, 1.0)
-[NoImage]      r = MixAudio(fr_bc, fc_lf, 1.0, 1.0)
-[NoImage]      return MergeChannels(l, r)
-[NoImage]   }
-[NoImage] # 4 Channels Quadro L,R,SL,SR -> Stereo
-[NoImage] function c4_stereo(clip a)
-[NoImage]   {
-[NoImage]      fl = GetChannel(a, 1)
-[NoImage]      fr = GetChannel(a, 2)
-[NoImage]      sl = GetChannel(a, 3)
-[NoImage]      sr = GetChannel(a, 4)
-[NoImage]      l = MixAudio(fl, sl, 0.5, 0.5)
-[NoImage]      r = MixAudio(fr, sr, 0.5, 0.5)
-[NoImage]      return MergeChannels(l, r)
-[NoImage]   }
-[NoImage] # 4 Channels L,R,C,LFE or L,R,S,LFE or L,R,C,S -> Stereo
-[NoImage] function c42_stereo(clip a)
-[NoImage]   {
-[NoImage]      fl = GetChannel(a, 1)
-[NoImage]      fr = GetChannel(a, 2)
-[NoImage]      fc = GetChannel(a, 3)
-[NoImage]      lf = GetChannel(a, 4)
-[NoImage]      fc_lf = MixAudio(fc, lf, 0.2929, 0.2929)
-[NoImage]      l = MixAudio(fl, fc_lf, 0.4142, 1.0)
-[NoImage]      r = MixAudio(fr, fc_lf, 0.4142, 1.0)
-[NoImage]      return MergeChannels(l, r)
-[NoImage]   }
-[NoImage] # 3 Channels L,R,C or L,R,S or L,R,LFE -> Stereo
-[NoImage] function c3_stereo(clip a)
-[NoImage]   {
-[NoImage]      fl = GetChannel(a, 1)
-[NoImage]      fr = GetChannel(a, 2)
-[NoImage]      fc = GetChannel(a, 3)
-[NoImage]      l = MixAudio(fl, fc, 0.5858, 0.4142)
-[NoImage]      r = MixAudio(fr, fc, 0.5858, 0.4142)
-[NoImage]      return MergeChannels(l, r)
-[NoImage]   }
-[NoImage] # 5.1 Channels L,R,C,LFE,SL,SR -> Dolby ProLogic
-[NoImage] function c6_dpl(clip a)
-[NoImage]   {
-[NoImage]      fl = GetChannel(a, 1)
-[NoImage]      fr = GetChannel(a, 2)
-[NoImage]      fc = GetChannel(a, 3)
-[NoImage]      sl = GetChannel(a, 5)
-[NoImage]      sr = GetChannel(a, 6)
-[NoImage]      bc = MixAudio(sl, sr, 0.2265, 0.2265)
-[NoImage]      fl_fc = MixAudio(fl, fc, 0.3205, 0.2265)
-[NoImage]      fr_fc = MixAudio(fr, fc, 0.3205, 0.2265)
-[NoImage]      l = MixAudio(fl_fc, bc, 1.0, 1.0)
-[NoImage]      r = MixAudio(fr_fc, bc, 1.0, -1.0)
-[NoImage]      return MergeChannels(l, r)
-[NoImage]   }
-[NoImage] # 5 Channels L,R,C,SL,SR -> Dolby ProLogic
-[NoImage] function c5_dpl(clip a)
-[NoImage]   {
-[NoImage]      fl = GetChannel(a, 1)
-[NoImage]      fr = GetChannel(a, 2)
-[NoImage]      fc = GetChannel(a, 3)
-[NoImage]      sl = GetChannel(a, 4)
-[NoImage]      sr = GetChannel(a, 5)
-[NoImage]      bc = MixAudio(sl, sr, 0.2265, 0.2265)
-[NoImage]      fl_fc = MixAudio(fl, fc, 0.3205, 0.2265)
-[NoImage]      fr_fc = MixAudio(fr, fc, 0.3205, 0.2265)
-[NoImage]      l = MixAudio(fl_fc, bc, 1.0, 1.0)
-[NoImage]      r = MixAudio(fr_fc, bc, 1.0, -1.0)
-[NoImage]      return MergeChannels(l, r)
-[NoImage]   }
-[NoImage] # 5 Channels L,R,LFE,SL,SR -> Dolby ProLogic
-[NoImage] function c52_dpl(clip a)
-[NoImage]   {
-[NoImage]      fl = GetChannel(a, 1)
-[NoImage]      fr = GetChannel(a, 2)
-[NoImage]      sl = GetChannel(a, 4)
-[NoImage]      sr = GetChannel(a, 5)
-[NoImage]      bc = MixAudio(sl, sr, 0.2929, 0.2929)
-[NoImage]      l = MixAudio(fl, bc, 0.4142, 1.0)
-[NoImage]      r = MixAudio(fr, bc, 0.4142, -1.0)
-[NoImage]      return MergeChannels(l, r)
-[NoImage]   }
-[NoImage] # 5 Channels L,R,C,LFE,S -> Dolby ProLogic
-[NoImage] function c53_dpl(clip a)
-[NoImage]   {
-[NoImage]      fl = GetChannel(a, 1)
-[NoImage]      fr = GetChannel(a, 2)
-[NoImage]      fc = GetChannel(a, 3)
-[NoImage]      bc = GetChannel(a, 5)
-[NoImage]      fl_fc = MixAudio(fl, fc, 0.4142, 0.2929)
-[NoImage]      fr_fc = MixAudio(fr, fc, 0.4142, 0.2929)
-[NoImage]      l = MixAudio(fl_fc, bc, 1.0, 0.2929)
-[NoImage]      r = MixAudio(fr_fc, bc, 1.0, -0.2929)
-[NoImage]      return MergeChannels(l, r)
-[NoImage]   }
-[NoImage] # 4 Channels Quadro L,R,SL,SR -> Dolby ProLogic
-[NoImage] function c4_dpl(clip a)
-[NoImage]   {
-[NoImage]      fl = GetChannel(a, 1)
-[NoImage]      fr = GetChannel(a, 2)
-[NoImage]      sl = GetChannel(a, 3)
-[NoImage]      sr = GetChannel(a, 4)
-[NoImage]      bc = MixAudio(sl, sr, 0.2929, 0.2929)
-[NoImage]      l = MixAudio(fl, bc, 0.4142, 1.0)
-[NoImage]      r = MixAudio(fr, bc, 0.4142, -1.0)
-[NoImage]      return MergeChannels(l, r)
-[NoImage]   }
-[NoImage] # 4 Channels L,R,LFE,S  -> Dolby ProLogic
-[NoImage] function c42_dpl(clip a)
-[NoImage]   {
-[NoImage]      fl = GetChannel(a, 1)
-[NoImage]      fr = GetChannel(a, 2)
-[NoImage]      bc = GetChannel(a, 4)
-[NoImage]      l = MixAudio(fl, bc, 0.5858, 0.4142)
-[NoImage]      r = MixAudio(fr, bc, 0.5858, -0.4142)
-[NoImage]      return MergeChannels(l, r)
-[NoImage]   }
-[NoImage] # 4 Channels L,R,C,S -> Dolby ProLogic
-[NoImage] function c43_dpl(clip a)
-[NoImage]   {
-[NoImage]      fl = GetChannel(a, 1)
-[NoImage]      fr = GetChannel(a, 2)
-[NoImage]      fc = GetChannel(a, 3)
-[NoImage]      bc = GetChannel(a, 4)
-[NoImage]      fl_fc = MixAudio(fl, fc, 0.4142, 0.2929)
-[NoImage]      fr_fc = MixAudio(fr, fc, 0.4142, 0.2929)
-[NoImage]      l = MixAudio(fl_fc, bc, 1.0, 0.2929)
-[NoImage]      r = MixAudio(fr_fc, bc, 1.0, -0.2929)
-[NoImage]      return MergeChannels(l, r)
-[NoImage]   }
-[NoImage] # 3 Channels L,R,S  -> Dolby ProLogic
-[NoImage] function c3_dpl(clip a)
-[NoImage]   {
-[NoImage]      fl = GetChannel(a, 1)
-[NoImage]      fr = GetChannel(a, 2)
-[NoImage]      bc = GetChannel(a, 3)
-[NoImage]      l = MixAudio(fl, bc, 0.5858, 0.4142)
-[NoImage]      r = MixAudio(fr, bc, 0.5858, -0.4142)
-[NoImage]      return MergeChannels(l, r)
-[NoImage]   }
-[NoImage] # 5.1 Channels L,R,C,LFE,SL,SR -> Dolby ProLogic II
-[NoImage] function c6_dpl2(clip a)
-[NoImage]   {
-[NoImage]      fl = GetChannel(a, 1)
-[NoImage]      fr = GetChannel(a, 2)
-[NoImage]      fc = GetChannel(a, 3)
-[NoImage]      sl = GetChannel(a, 5)
-[NoImage]      sr = GetChannel(a, 6)
-[NoImage]      ssl = MixAudio(sl, sr, 0.2818, 0.1627)
-[NoImage]      ssr = MixAudio(sl, sr, -0.1627, -0.2818)
-[NoImage]      fl_fc = MixAudio(fl, fc, 0.3254, 0.2301)
-[NoImage]      fr_fc = MixAudio(fr, fc, 0.3254, 0.2301)
-[NoImage]      l = MixAudio(fl_fc, ssl, 1.0, 1.0)
-[NoImage]      r = MixAudio(fr_fc, ssr, 1.0, 1.0)
-[NoImage]      return MergeChannels(l, r)
-[NoImage]   }
-[NoImage] # 5 Channels L,R,C,SL,SR -> Dolby ProLogic II
-[NoImage] function c5_dpl2(clip a)
-[NoImage]   {
-[NoImage]      fl = GetChannel(a, 1)
-[NoImage]      fr = GetChannel(a, 2)
-[NoImage]      fc = GetChannel(a, 3)
-[NoImage]      sl = GetChannel(a, 4)
-[NoImage]      sr = GetChannel(a, 5)
-[NoImage]      ssl = MixAudio(sl, sr, 0.2818, 0.1627)
-[NoImage]      ssr = MixAudio(sl, sr, -0.1627, -0.2818)
-[NoImage]      fl_fc = MixAudio(fl, fc, 0.3254, 0.2301)
-[NoImage]      fr_fc = MixAudio(fr, fc, 0.3254, 0.2301)
-[NoImage]      l = MixAudio(fl_fc, ssl, 1.0, 1.0)
-[NoImage]      r = MixAudio(fr_fc, ssr, 1.0, 1.0)
-[NoImage]      return MergeChannels(l, r)
-[NoImage]   }
-[NoImage] # 5 Channels L,R,LFE,SL,SR -> Dolby ProLogic II
-[NoImage] function c52_dpl2(clip a)
-[NoImage]   {
-[NoImage]      fl = GetChannel(a, 1)
-[NoImage]      fr = GetChannel(a, 2)
-[NoImage]      sl = GetChannel(a, 4)
-[NoImage]      sr = GetChannel(a, 5)
-[NoImage]      ssl = MixAudio(sl, sr, 0.3714, 0.2144)
-[NoImage]      ssr = MixAudio(sl, sr, -0.2144, -0.3714)
-[NoImage]      l = MixAudio(fl, ssl, 0.4142, 1.0)
-[NoImage]      r = MixAudio(fr, ssr, 0.4142, 1.0)
-[NoImage]      return MergeChannels(l, r)
-[NoImage]   }
-[NoImage] # 4 Channels Quadro L,R,SL,SR -> Dolby ProLogic II
-[NoImage] function c4_dpl2(clip a)
-[NoImage]   {
-[NoImage]      fl = GetChannel(a, 1)
-[NoImage]      fr = GetChannel(a, 2)
-[NoImage]      sl = GetChannel(a, 3)
-[NoImage]      sr = GetChannel(a, 4)
-[NoImage]      ssl = MixAudio(sl, sr, 0.3714, 0.2144)
-[NoImage]      ssr = MixAudio(sl, sr, -0.2144, -0.3714)
-[NoImage]      l = MixAudio(fl, ssl, 0.4142, 1.0)
-[NoImage]      r = MixAudio(fr, ssr, 0.4142, 1.0)
-[NoImage]      return MergeChannels(l, r)
-[NoImage]   }
--[Information] [04/04/18 00:38:09] AviSynth script
--[Information] [04/04/18 00:38:09] Command line used: -ignorelength -br 128000 -if - -of "{0}"
--[Information] [04/04/18 00:38:09] AviSynth script environment opened
--[Information] [04/04/18 00:38:15] Script loaded
--[Information] [04/04/18 00:38:15] Output Decoder
---[Information] [04/04/18 00:38:15] Channels: 2
---[Information] [04/04/18 00:38:15] Bits per sample: 32
---[Information] [04/04/18 00:38:15] Sample rate: 48000
--[Information] [04/04/18 00:38:15] Job command line: C:\Users\USER\MeGUI\tools\eac3to\neroAacEnc.exe -ignorelength -br 128000 -if - -of "C:\Users\USER\Desktop\MeGUI Output\AUDIO.m4a"
--[Information] [04/04/18 00:38:16] Process started
--[Information] [04/04/18 00:38:16] Standard output stream
--[Information] [04/04/18 00:38:16] Standard error stream
So this is the log, do you see something weird?
Is it possible to copy a log of ffmpeg?
doomleox999 is offline   Reply With Quote
Old 4th April 2018, 05:42   #5  |  Link
hello_hello
Registered User
 
Join Date: Mar 2011
Posts: 4,823
Quote:
Originally Posted by doomleox999 View Post
So this is the log, do you see something weird?
Nothing that I can see.

Quote:
-[NoImage] # detected channels: 6
-[NoImage] # detected channel positions: 3/2/0.1
-[NoImage] LoadPlugin("C:\Users\USER\MeGUI\tools\avisynth_plugin\AudioLimiter.dll")
-[NoImage] c6_stereo(ConvertAudioToFloat(last))
-[NoImage] Normalize()
-[NoImage] return last
Quote:
-[NoImage] # 5.1 Channels L,R,C,LFE,SL,SR -> stereo + LFE
-[NoImage] function c6_stereo(clip a)
-[NoImage] {
-[NoImage] fl = GetChannel(a, 1)
-[NoImage] fr = GetChannel(a, 2)
-[NoImage] fc = GetChannel(a, 3)
-[NoImage] lf = GetChannel(a, 4)
-[NoImage] sl = GetChannel(a, 5)
-[NoImage] sr = GetChannel(a, 6)
-[NoImage] fl_sl = MixAudio(fl, sl, 0.2929, 0.2929)
-[NoImage] fr_sr = MixAudio(fr, sr, 0.2929, 0.2929)
-[NoImage] fc_lf = MixAudio(fc, lf, 0.2071, 0.2071)
-[NoImage] l = MixAudio(fl_sl, fc_lf, 1.0, 1.0)
-[NoImage] r = MixAudio(fr_sr, fc_lf, 1.0, 1.0)
-[NoImage] return MergeChannels(l, r)
-[NoImage] }
The first quoted section shows MeGUI is downmixing with the c6_stereo() function, followed by Normalize(), and the second quoted section shows the c6_stereo() function, which seems normal.

0.2929 means the front left and surround left channels are being downmixed with a (roughly) 10.5dB volume reduction for each. The same applies to FR and SR.
0.2071 means the centre and LFE channels are being mixed together with a (roughly) 13.5dB reduction, then they're added to left and right. The upshot is, the centre and LFE channels have their volumes reduced by 3dB relative to the other channels, which is normal.

That's a fair volume reduction, but Normalize() will increase it again until the peaks are at maximum. Sometimes they're very close to maximum anyway (hence reducing the volume so much to prevent clipping when downmixing) and Normalize() will therefore not increase the volume much.

You could try importing the downmixed audio into Auidacity to see if it can be amplified without clipping, but you shouldn't be able to.

You can also try downmixing with one of the Pro Logic stereo options. They should sound the same as normal stereo but they don't include the LFE channel, which means the rest of the channels are mixed together at a slightly higher volume, and you might find the peaks are coming from a loud LFE channel, so Normalize() will have more effect without it. I never include the LFE channel when downmixing, but unfortunately there's no option to not include it when downmixing to normal stereo with MeGUI.

Quote:
Originally Posted by doomleox999 View Post
Is it possible to copy a log of ffmpeg?
Add -report to the beginning of the command line and ffmpeg should save a log file.

I think it's likely ffmpeg isn't reducing the volume to prevent possible clipping (or maybe it uses Pro Logic downmixing by default?) but I've never used it for downmixing so I don't know how much the log file will tell you about it.

Last edited by hello_hello; 4th April 2018 at 05:52.
hello_hello is offline   Reply With Quote
Old 4th April 2018, 09:01   #6  |  Link
tebasuna51
Moderator
 
tebasuna51's Avatar
 
Join Date: Feb 2005
Location: Spain
Posts: 6,890
The ffmpeg log don't say the matrix used to downmix. In my test I found than use:

FL' = FL + 0.7*FC + 0.7*SL
FR' = FR + 0.7*FC + 0.7*SR

- A simple stereo downmix is used.
- The LFE is ignored (recommended).
- Don't prevent clip. Volume values until 2.4 can be obtained and all values over 1.0 are clipped.

The matrix used in MeGUI function c6_stereo is:

FL' = 0.2929*FL + 0.2071*FC + 0.2071*LFE + 0.2929*SL
FR' = 0.2929*FR + 0.2071*FC + 0.2071*LFE + 0.2929*SR

Is a matrix with normalized coeficients than can output a max volume value of 1.0 (without clip)
To avoid low volume values after mix is Normalized to obtain max volume without clip.

----------------------------------------------

You can use BeHappy to downmix with more options to prevent the know problem of low volume dialogs.
For instance simple Stereo without LFE:

FL' = 0.3694*FL + 0.2612*FC + 0.3694*SL
FR' = 0.3694*FR + 0.2612*FC + 0.3694*SR

Or 'Night Mode' forcing Center channel:

FL' = 0.1875*FL + 0.625*FC + 0.1875*SL
FR' = 0.1875*FR + 0.625*FC + 0.1875*SR

Or 'Simple (F+C)':

FL' = FL + 0.7071*FC
FR' = FR + 0.7071*FC

Even you can make your script with the desired mix.
__________________
BeHappy, AviSynth audio transcoder.
tebasuna51 is offline   Reply With Quote
Old 4th April 2018, 18:11   #7  |  Link
mkver
Registered User
 
Join Date: May 2016
Posts: 197
With -loglevel debug or higher ffmpeg tells you the matrix used:
Code:
[Parsed_aresample_0 @ 0000000000191080] [SWR @ 00000000001a1000] Using fltp internally between filters
[Parsed_aresample_0 @ 0000000000191080] [SWR @ 00000000001a1000] Matrix coefficients:
[Parsed_aresample_0 @ 0000000000191080] [SWR @ 00000000001a1000] FL: FL:0.414214 FR:0.000000 FC:0.292893 LFE:0.000000 SL:0.292893 SR:0.000000 
[Parsed_aresample_0 @ 0000000000191080] [SWR @ 00000000001a1000] FR: FL:0.000000 FR:0.414214 FC:0.292893 LFE:0.000000 SL:0.000000 SR:0.292893 
[Parsed_aresample_0 @ 0000000000191080] ch:6 chl:5.1(side) fmt:fltp r:48000Hz -> ch:2 chl:stereo fmt:s16 r:48000Hz
mkver is offline   Reply With Quote
Old 4th April 2018, 21:09   #8  |  Link
tebasuna51
Moderator
 
tebasuna51's Avatar
 
Join Date: Feb 2005
Location: Spain
Posts: 6,890
You are right, using -loglevel debug the matrix is showed, but the mine confirm my first post with clip problems:

Code:
[auto_resampler_0 @ 0000000000440a40] [SWR @ 0000000002b21140] Using fltp internally between filters
[auto_resampler_0 @ 0000000000440a40] [SWR @ 0000000002b21140] Matrix coefficients:
[auto_resampler_0 @ 0000000000440a40] [SWR @ 0000000002b21140] FL: FL:1.000000 FR:0.000000 FC:0.707107 LFE:0.000000 BL:0.707107 BR:0.000000
[auto_resampler_0 @ 0000000000440a40] [SWR @ 0000000002b21140] FR: FL:0.000000 FR:1.000000 FC:0.707107 LFE:0.000000 BL:0.000000 BR:0.707107
__________________
BeHappy, AviSynth audio transcoder.
tebasuna51 is offline   Reply With Quote
Old 5th April 2018, 13:00   #9  |  Link
hello_hello
Registered User
 
Join Date: Mar 2011
Posts: 4,823
Is the difference in log files the difference between using -ac 2 and the audio resampler function, whatever the command line for using it might be? It appears the audio resampler has some sort of clipping prevention (rematrix_maxval) although by the description I assume it performs some sort of peak limiting rather than peak normalising.
hello_hello is offline   Reply With Quote
Old 5th April 2018, 13:20   #10  |  Link
mkver
Registered User
 
Join Date: May 2016
Posts: 197
1. If I use -ac2 the only difference I get is that it now reports "auto_resampler", not the explicitly called "Parsed_aresample":
Code:
[auto_resampler_0 @ 0000000000169a00] [SWR @ 0000000000169c40] Using fltp internally between filters
[auto_resampler_0 @ 0000000000169a00] [SWR @ 0000000000169c40] Matrix coefficients:
[auto_resampler_0 @ 0000000000169a00] [SWR @ 0000000000169c40] FL: FL:0.414214 FR:0.000000 FC:0.292893 LFE:0.000000 SL:0.292893 SR:0.000000 
[auto_resampler_0 @ 0000000000169a00] [SWR @ 0000000000169c40] FR: FL:0.000000 FR:0.414214 FC:0.292893 LFE:0.000000 SL:0.000000 SR:0.292893 
[auto_resampler_0 @ 0000000000169a00] ch:6 chl:5.1(side) fmt:fltp r:48000Hz -> ch:2 chl:stereo fmt:s16 r:48000Hz
2. I use an input file that ffmpeg detects as 5.1(side), whereas your file has back channels according to ffmpeg. I don't think that this is the reason behind the difference, but it should be noted. My ffmpeg has been built less than two weeks ago, when has yours?
3. My first test was with using aresample like this: -filter:a aresample=ocl=stereo
mkver is offline   Reply With Quote
Old 5th April 2018, 15:49   #11  |  Link
tebasuna51
Moderator
 
tebasuna51's Avatar
 
Join Date: Feb 2005
Location: Spain
Posts: 6,890
EDIT: I used only the parameter -ac 2 to let ffmpeg select the default downmix...

We can also instruct ffmpeg with the desired downmix using a filter, for instance:

-af "pan=stereo|FL < FL + .7FC + .3BL + .3SL + 0.2LFE|FR < FR + .7FC + .3BR + .3SR + 0.2LFE"

But the problem is always the same, with normalized coeficients => low volume, with big coeficients => more volume but clip risk.
__________________
BeHappy, AviSynth audio transcoder.

Last edited by tebasuna51; 5th April 2018 at 15:59.
tebasuna51 is offline   Reply With Quote
Old 5th April 2018, 18:33   #12  |  Link
hello_hello
Registered User
 
Join Date: Mar 2011
Posts: 4,823
Quote:
Originally Posted by mkver View Post
1. If I use -ac2 the only difference I get is that it now reports "auto_resampler", not the explicitly called "Parsed_aresample"
Could the type of audio being downmixed make a difference? What sort of audio were you using as the source?

AC3 has rules about how 5.1ch is supposed to be downmixed to stereo, and if ffmpeg is following those rules when decoding and downmixing, it'd probably apply a volume reduction. I think it's around 7.5dB over-all, which is roughly what it seems to be doing in your case.

I wonder if ffmpeg might downmix different sources differently? I might play around with it tomorrow if I get a chance. I've not downmixed with ffmpeg before.
hello_hello is offline   Reply With Quote
Old 5th April 2018, 18:59   #13  |  Link
mkver
Registered User
 
Join Date: May 2016
Posts: 197
My source was a 5.1 ac3 file (which ffmeg treats as 5.1(side) -- ac3 only has one 5.1 channel layout); I just decoded said file to a 5.1(side) wav file to get rid of any special information for downmixing. And if I downmix said wav file, I get exactly the same coefficients as before. If I decode the ac3 and resample to 5.1 (with back channels), the side channels are simply copied to the back channels (and the other channels stay the same). If I downmix said file to stereo, I get the same coefficients as in the 5.1(side) case (just with BL/BR instead of SL/SR). So I can only think of two more possibilities: tebasuna51 uses a different ffmpeg version or he uses a file with embedded downmix coefficients that are honored by ffmpeg.
mkver is offline   Reply With Quote
Old 5th April 2018, 22:58   #14  |  Link
doomleox999
Registered User
 
Join Date: Nov 2015
Posts: 81
Wow you guys know a lot about this, I can't understand everything you are talking about (specially "clipping") but I think that MeGUI DOES something different than ffmpeg and that's the reason why they deliver different results. What is not clear for me is if you can instruct MeGUI to (forgive my ignorance) downmix just like ffmpeg does, do I have to add some lines to the script?
doomleox999 is offline   Reply With Quote
Old 6th April 2018, 11:22   #15  |  Link
tebasuna51
Moderator
 
tebasuna51's Avatar
 
Join Date: Feb 2005
Location: Spain
Posts: 6,890
Quote:
Originally Posted by hello_hello View Post
AC3 has rules about how 5.1ch is supposed to be downmixed to stereo, and if ffmpeg is following those rules when decoding and downmixing...
You are right, in the header of AC3 there are fields:
Code:
Center mix level
    0 = -3.0 dB (default in Aften encode, recommended)
    1 = -4.5 dB (default in ffmpeg encode)
    2 = -6.0 dB
Surround mix level
    0 = -3 dB (default in Aften encode)
    1 = -6 dB (default in ffmpeg encode, recommended)
    2 = 0
than can be used by ffmpeg, but the source of doomleox999 is a sixchannels.aac, and ADTS aac headers don't have that fields.

I used wav input files to let free ffmpeg downmix.

BTW the question is what downmix matrix use, we can force to ffmpeg use any custom matrix (-af "pan=stereo...") and we can use any downmix script with AviSynth.

When try to play with only 2 speakers we can't obtain the same volume than using 6 speakers, we need choice between less volume (normalized coeficients) or distort high volumes (signal clip).

What is clip? (short explain)
Audio samples can be stored in float formats without limits of volume.
But always must be converted to int samples (at least at end of digital-analog conversion).

And float values greater than 1.0 are truncated to 1.0 and asigned to max integer allowed.
Values greater than 1.0 are lossed, in a audio editor show like a clip (red values in image):
Attached Images
 
__________________
BeHappy, AviSynth audio transcoder.
tebasuna51 is offline   Reply With Quote
Old 6th April 2018, 12:15   #16  |  Link
tebasuna51
Moderator
 
tebasuna51's Avatar
 
Join Date: Feb 2005
Location: Spain
Posts: 6,890
Quote:
Originally Posted by doomleox999 View Post
...if you can instruct MeGUI to downmix just like ffmpeg does...?
Yes, but what ffmpeg do?

Y tried with a sixchannels.aac and now uses:

Code:
[auto_resampler_0 @ 0000000002bf5140] [SWR @ 0000000002bf5240] Matrix coefficients:
[auto_resampler_0 @ 0000000002bf5140] [SWR @ 0000000002bf5240] FL: FL:0.414214 FR:0.000000 FC:0.292893 LFE:0.000000 BL:0.292893 BR:0.000000
[auto_resampler_0 @ 0000000002bf5140] [SWR @ 0000000002bf5240] FR: FL:0.000000 FR:0.414214 FC:0.292893 LFE:0.000000 BL:0.000000 BR:0.292893
or:
Code:
FL' = 0.414214*FL + 0.292893*FC + 0.292893*SL
FR' = 0.414214*FR + 0.292893*FC + 0.292893*SR
Is a normalized mix without clip, the difference with MeGUI is don't use the LFE channel (like is recommended) but is not a big diference in volume:

Front coeficient 0.4 versus 0.3
Center coeficient 0.3 versus 0.2

And MeGUI do a last Normalize to obtain max volume without clip, ffmpeg don't normalize at end.

You can use the same mix and Normalize at end with this script:

Code:
ClearAutoloadDirs()
AddAutoloadDir("C:\Users\USER\MeGUI\tools\avs\plugins")
LoadPlugin("C:\Users\USER\MeGUI\tools\lsmash\LSMASHSource.dll")
a=LWLibavAudioSource("C:\Users\USER\Desktop\MeGUI Output\AUDIO.aac")

  fl = GetChannel(a, 1)
  fr = GetChannel(a, 2)
  fc = GetChannel(a, 3)
#  lf = GetChannel(a, 4)
  sl = GetChannel(a, 5)
  sr = GetChannel(a, 6)
  fl_sl = MixAudio(fl, sl, 0.414214, 0.292893)
  fr_sr = MixAudio(fr, sr, 0.414214, 0.292893)
  l = MixAudio(fl_sl, fc, 1.0, 0.292893)
  r = MixAudio(fr_sr, fc, 1.0, 0.292893)
  MergeChannels(l, r)

Normalize()
return last
__________________
BeHappy, AviSynth audio transcoder.

Last edited by tebasuna51; 6th April 2018 at 12:20.
tebasuna51 is offline   Reply With Quote
Old 7th April 2018, 06:51   #17  |  Link
doomleox999
Registered User
 
Join Date: Nov 2015
Posts: 81
So I just load that script in "Audio Input" in MeGUI? Is that how it works?

By the way, I was testing 6ch to stereo again with ffmpeg and the same file and something new happened at the end of the encode. To be honest I'm not sure if it happened everytime before, I'm talking about those red lines at the bottom:

doomleox999 is offline   Reply With Quote
Old 7th April 2018, 08:31   #18  |  Link
tebasuna51
Moderator
 
tebasuna51's Avatar
 
Join Date: Feb 2005
Location: Spain
Posts: 6,890
Quote:
Originally Posted by doomleox999 View Post
So I just load that script in "Audio Input" in MeGUI? Is that how it works?
Yes, put the megui log to confirm.

Quote:
By the way, I was testing 6ch to stereo again with ffmpeg and the same file and something new happened at the end of the encode. To be honest I'm not sure if it happened everytime before, I'm talking about those red lines at the bottom:
ffmpeg show that message when Noise scalefactors are greater than 30.
Maybe it is a encoder bug or a file corruption, it don't seems critical.
__________________
BeHappy, AviSynth audio transcoder.
tebasuna51 is offline   Reply With Quote
Old 9th April 2018, 11:54   #19  |  Link
doomleox999
Registered User
 
Join Date: Nov 2015
Posts: 81
So the noise scalefactors thing from ffmpeg is not important? Even if they are red? (I sound childish haha but if the program use red I'd guess is for a reason)

I get the same result with the custom script, just to be sure, this is where I have to load it right?

doomleox999 is offline   Reply With Quote
Old 9th April 2018, 16:02   #20  |  Link
tebasuna51
Moderator
 
tebasuna51's Avatar
 
Join Date: Feb 2005
Location: Spain
Posts: 6,890
Quote:
Originally Posted by doomleox999 View Post
So the noise scalefactors thing from ffmpeg is not important? Even if they are red?
I say not critical because is a problem in the source file than can't be corrected. If sound bad at some point we can do nothing, maybe find other source file.

There are other message (yelow) to suspect over the encoder than make this aac file.

Quote:
I get the same result with the custom script, just to be sure, this is where I have to load it right?
Yes.

BTW the in the Config Encoder Settings you can't use a preset for multichannel if you downmix to stereo.
For a stereo with a bitrate near 128 Kb/s (absolutely not recomended for multichannel) you can use a VBR with Q = 0.4

Also if downmix and Normalize are already in the .avs don't repeat them, use some config like:
Attached Images
 
__________________
BeHappy, AviSynth audio transcoder.
tebasuna51 is offline   Reply With Quote
Reply

Tags
6channels, ffmpeg, megui, stereo

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 15:12.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.