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 > Capturing and Editing Video > VirtualDub, VDubMod & AviDemux

Reply
 
Thread Tools Search this Thread Display Modes
Old 31st July 2015, 22:13   #1  |  Link
atamo
Registered User
 
Join Date: Apr 2008
Posts: 10
VirtualDub AC3-multichannel

Hy!
VirtualDub supports only stereo audio in full processing mode or is possible 6 chanels mode?
I want to increase volum level for an avi file.
I've AC3-ACM installed

Quote:
Originally Posted by Audio properties:

Format : AC-3

mode : Constant
Bit rate : 384 Kbps
Channel(s) : 5.1channels
Sampling rate : 48.0 KHz
Bit depth : 16 bits
I used direct stream copy for video and AC-3 ACM Codec 384kBit/s 48000Hz 5.1Channels audio compression, but I got :




Any help apreciated
atamo is offline   Reply With Quote
Old 1st August 2015, 15:10   #2  |  Link
LoRd_MuldeR
Software Developer
 
LoRd_MuldeR's Avatar
 
Join Date: Jun 2005
Location: Last House on Slunk Street
Posts: 13,230
Isn't the AC3-ACM "Codec" for decoding only?
__________________
Go to https://standforukraine.com/ to find legitimate Ukrainian Charities 🇺🇦✊
LoRd_MuldeR is offline   Reply With Quote
Old 1st August 2015, 15:30   #3  |  Link
raffriff42
Retried Guesser
 
raffriff42's Avatar
 
Join Date: Jun 2012
Posts: 1,373
Nope,
http://www.videohelp.com/software/AC3-ACM-Decompressor (page says 'decoder' but note the compression dialog screenshot)
http://www.digital-digest.com/dvd/do...c3acm_529.html (alternate link with more info)

...it handles multichannel, but not if any filtering is done, such as volume adjustment.

So you were correct atamo, unfortunately: VirtualDub supports only stereo audio in full processing mode.

Last edited by raffriff42; 17th March 2017 at 00:18. Reason: (fixed image link)
raffriff42 is offline   Reply With Quote
Old 1st August 2015, 17:48   #4  |  Link
raffriff42
Retried Guesser
 
raffriff42's Avatar
 
Join Date: Jun 2012
Posts: 1,373
You could "Save WAV" (in direct stream copy mode), manipulate the audio in Audacity, save the result as WAV, and import it back with VirtualDub's "Audio from another file." This method allows you to keep any timeline editing you may have done.

Last edited by raffriff42; 1st August 2015 at 18:13. Reason: typo
raffriff42 is offline   Reply With Quote
Old 14th August 2015, 20:27   #5  |  Link
atamo
Registered User
 
Join Date: Apr 2008
Posts: 10
Hy !
Unfortunately I don't have 5.1 system I use my stereo TV, and all videos with 5.1 sounds very quiet because the TV don't uses the center channnel, so I need to mix the center channel in left and right TV channel.

Anyone knows Virtualdub's multichanel to stereo convert formula ?
For example from 5.1 AC3 sound I got this stereo sound with Virtualdub


If I use Audacity the sound volume is double (if use -3db Gain for center)
atamo is offline   Reply With Quote
Old 14th August 2015, 20:48   #6  |  Link
wonkey_monkey
Formerly davidh*****
 
wonkey_monkey's Avatar
 
Join Date: Jan 2004
Posts: 2,370
Quote:
all videos with 5.1 sounds very quiet because the TV don't uses the center channnel
If your TV understands 5.1 at all, it's odd that it would ignore the center channel. And if it was just using the left and right tracks, you'd quite likely not hear any dialogue at all in most scenes. Is that the case, or is it just too quiet but otherwise normal?

5.1 soundtracks can sound too quiet on some setups, compared to other sources.
__________________
My AviSynth filters / I'm the Doctor
wonkey_monkey is offline   Reply With Quote
Old 16th August 2015, 09:30   #7  |  Link
atamo
Registered User
 
Join Date: Apr 2008
Posts: 10
Quote:
Originally Posted by davidhorman View Post

. . . is it just too quiet but otherwise normal
Probably my TV makes some mix with center channel but I can't control that and the result is very, very quiet with all 5.1 sources

Therefore must convert 5.1 to stereo with Audiocity or direct with Virtualdub but I want to knows Virtualdub's multichanel to stereo convert formula. Someone can help me with this?
for example: Left=L+0.7C+Ls
  • L=5.1Left
  • C=Center
  • Ls=Left Surround
atamo is offline   Reply With Quote
Old 16th August 2015, 10:44   #8  |  Link
AlexKane
Registered User
 
AlexKane's Avatar
 
Join Date: Jul 2014
Posts: 20
Quote:
Probably my TV makes some mix with center channel but I can't control that and the result is very, very quiet with all 5.1 sources
It is neither your fault nor your TV's. This is how it is supposed to sound in movie theaters. Since there is no "standard" for home playback levels (speakers, headphones etc)
there is no solution that will consistently improve what you already have (assuming you convert multichannel streams to stereo ones).
The mixing engineer will mix for theatrical presentations, not your home... thus the 5.1 -> 2.0 downmix will, by and large, be incompatible with what you expect to hear
(unless it is a Dolby track with a preserved dialnorm flag, played on a player that understands DRC metadata). As you accurately noticed, it happens with all 5.1 sources.

What you are looking for, in order to obtain sane levels for your listening environment is this.


Sadly, it is a proprietary piece of technology developed by Dolby Labs that only applies to their equally proprietary .ac3 streams. It is the sole reason why DVDs didn't
suffer from the problem you observed and also BluRays with DD and / or ThrueHD don't either.
AlexKane is offline   Reply With Quote
Old 20th August 2015, 04:02   #9  |  Link
hello_hello
Registered User
 
Join Date: Mar 2011
Posts: 4,612
Quote:
Originally Posted by atamo View Post
Probably my TV makes some mix with center channel but I can't control that and the result is very, very quiet with all 5.1 sources

Therefore must convert 5.1 to stereo with Audiocity or direct with Virtualdub but I want to knows Virtualdub's multichanel to stereo convert formula. Someone can help me with this?
for example: Left=L+0.7C+Ls
  • L=5.1Left
  • C=Center
  • Ls=Left Surround
Maybe it's something like:
Left = 0.37*L + 0.27*C + 0.37*Ls

Which would be similar to your formula above, only with each channel reduced by a fair amount to prevent any possibility of clipping if there's peaks already at maximum. It'd explain why the resulting volume is much lower.

Generally you'd downmix using a similar formula (I'm not sure if the percentages are exactly correct off the top of my head), then normalise to raise the peaks to maximum, but I don't think VirtualDub has a normalise function. You'd probably need to load the downmixed audio into another program for that, which would defeat the purpose of using VirtualDub to downmix. Can you extract the audio and use another program? TAudioConverter should downmix and normalise. MeGUI's audio encoding section will do it. You could probably load an AVI and re-encode the audio without having to extract it first, then you could replace the old audio with the stereo version yourself using VirtualDub.

It's unlikely your TV is ignoring the centre channel. Is it only AC3 audio that's a problem? Is it only 5.1ch AC3 and not stereo AC3? Maybe the TV is obeying any dialogue normalisation written to the AC3 stream, which usually results in a volume reduction. It might pay to also make sure the TV doesn't have any sort of "night mode" for audio. Or maybe the TV is also using a similar "worst case scenario" matrix for downmixing, which is why it tends to sound quieter.

PS. I've never used VirtualDub for encoding audio, but if it only supports stereo in full processing mode, why does it have an option for setting the number of audio channels under the Audio/Conversion menu?

Last edited by hello_hello; 20th August 2015 at 05:16.
hello_hello is offline   Reply With Quote
Old 20th August 2015, 05:27   #10  |  Link
raffriff42
Retried Guesser
 
raffriff42's Avatar
 
Join Date: Jun 2012
Posts: 1,373
In the ea3to thread there is this from tebasuna51...
http://forum.doom9.org/showthread.ph...54#post1712854

...which points to "ITU-R BS.775-3.pdf"
http://www.itu.int/rec/R-REC-BS.775-3-201208-I/ee

Here's "Downward mixing of multichannel audio signals" from the PDF page 11, reformatted:
Code:
Mono – 1/0 format 
         L      R      C      LS    RS
C ' = 0.7071 0.7071 1.0000 0.5000 0.5000

Stereo – 2/0 format 
         L      R      C      LS    RS
L ' = 1.0000 0.0000 0.7071 0.7071 0.0000
R ' = 0.0000 1.0000 0.7071 0.0000 0.7071

Three channels – 3/0 format 
         L      R      C      LS    RS
L ' = 1.0000 0.0000 0.0000 0.7071 0.0000
R ' = 0.0000 1.0000 0.0000 0.0000 0.7071
C ' = 0.0000 0.0000 1.0000 0.0000 0.0000

Three channels – 2/1 format 
         L      R      C      LS    RS
L ' = 1.0000 0.0000 0.7071 0.0000 0.0000
R ' = 0.0000 1.0000 0.7071 0.0000 0.0000
S ' = 0.0000 0.0000 0.0000 0.7071 0.7071

Four channels – 3/1 format 
         L      R      C      LS    RS
L ' = 1.0000 0.0000 0.0000 0.0000 0.0000
R ' = 0.0000 1.0000 0.0000 0.0000 0.0000
C ' = 0.0000 0.0000 1.0000 0.0000 0.0000
S ' = 0.0000 0.0000 0.0000 0.7071 0.7071

Four channels – 2/2 format 
         L      R      C      LS    RS
L ' = 1.0000 0.0000 0.7071 0.0000 0.0000
R ' = 0.0000 1.0000 0.7071 0.0000 0.0000
LS' = 0.0000 0.0000 0.0000 1.0000 0.0000
RS' = 0.0000 0.0000 0.0000 0.0000 1.0000
(note LFE is never added - see discussion at the link)

EDIT I'm just quoting the standard docs; if AlexKane is saying you need to adjust your mix for a particular source to make it sound right, I would not disagree.

Last edited by raffriff42; 20th August 2015 at 05:37.
raffriff42 is offline   Reply With Quote
Old 20th August 2015, 05:57   #11  |  Link
hello_hello
Registered User
 
Join Date: Mar 2011
Posts: 4,612
I must have been bored because I found myself experimenting with ways to downmix with VirtualDub. With the help of Avisynth, this seems to work. Someone else may be able to suggest a more clever way.

Create an AVISource script to open an AVI with 5.1ch audio and add the audio downmixing and normalising to the script.

Quote:
AVISource("D:\test.avi")

function Downmix(clip a)
{
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.2929, 0.2929)
fr_sr = MixAudio(fr, sr, 0.2929, 0.2929)
fc_lf = MixAudio(fc, lf, 0.2071, 0.2071)
l = MixAudio(fl_sl, fc_lf, 1.0, 1.0)
r = MixAudio(fr_sr, fc_lf, 1.0, 1.0)
MergeChannels(l, r)
}

Downmix(ConvertAudioToFloat(last))
Normalize()
return last
Open the AVI with VirtualDub (not the script).
Under the Audio menu, select "audio from other file" then select the Avisynth script as the source audio.
If you're not re-encoding the video, choose Direct Stream Copy for the video compression and full processing for the audio. Choose whichever codec for compression you prefer and/or have installed (ie MP3, or AC3 etc).
Save that as a new AVI.
It'll probably take a minute or two before the processing starts while Avisynth scans and checks the audio peaks, but when the new AVI is saved it should contain stereo audio at maximum volume.

I had to test the above using DirectShowSource as I don't have an ACM codec installed for decoding AC3, but I'm pretty sure it'd work using AviSource. I don't see why not.

The above script would downmix 5.1ch audio while including the LFE channel. If you'd prefer to downmix without it, this should do it:

Quote:
AVISource("D:\test.avi")

function Downmix(clip a)
{
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.3694, 0.3694)
fr_sr = MixAudio(fr, sr, 0.3694, 0.3694)
l = MixAudio(fl_sl, fc, 1.0, 0.2612)
r = MixAudio(fr_sr, fc, 1.0, 0.2612)
MergeChannels(l, r)
}

Downmix(ConvertAudioToFloat(last))
Normalize()
return last
I pinched the percentages and script ideas from MeGUI's log file so they should be right....

Last edited by hello_hello; 20th August 2015 at 06:18.
hello_hello is offline   Reply With Quote
Old 20th August 2015, 06:15   #12  |  Link
hello_hello
Registered User
 
Join Date: Mar 2011
Posts: 4,612
Quote:
Originally Posted by raffriff42 View Post
In the ea3to thread there is this from tebasuna51...
http://forum.doom9.org/showthread.ph...54#post1712854
That seems right, but remember eac3to also has a function for detecting clipping, so if it detects clipping after downmixing it can reduce the volume.

Doing it the other way around probably requires worst case scenario downmixing, then normalising afterwards.

The Dolby AC3 spec for downmixing 5.1ch audio uses a similar formula to eac3to (only I think the exact levels for downmixing the surround and centre channels can be specified in the AC3 stream) with a further overall 7.5dB gain reduction to prevent clipping (I'm pretty sure).

There's a post here referring to the formula SOX uses, which appears to be the same as the one MeGUI uses, without the LFE channel.
http://www.hydrogenaud.io/forums/ind...9&#entry855199

Quote:
Originally Posted by raffriff42 View Post
EDIT I'm just quoting the standard docs; if AlexKane is saying you need to adjust your mix for a particular source to make it sound right, I would not disagree.
The TV in the living room here has a couple of different "night modes". I can't remember what they're called but they basically compress the audio. One seems to boost it quite a bit. It's not perfect.... I can hear "pumping" of background sounds on occasion.... but it's definitely better than constantly turning the volume up and down due to overly-dynamic audio.
Me.... I use my PC as a media player, ffdshow for audio decoding, and it's Winamp filter to run a compressor plugin.

Last edited by hello_hello; 20th August 2015 at 06:40.
hello_hello is offline   Reply With Quote
Old 20th August 2015, 08:39   #13  |  Link
raffriff42
Retried Guesser
 
raffriff42's Avatar
 
Join Date: Jun 2012
Posts: 1,373
Quote:
Originally Posted by hello_hello View Post
If you'd prefer to downmix without it, this should do it...
I had something very much like it. I think you're right to convert to float first and normalize afterwards.

Here's your Downmix function modded with adjustable gains, plus an optional delay effect on the surrounds, which might help emulate the back-speaker sound (I think Dolby does something like this):
Code:
function Downmix(clip a, float "centergain", float "surroundgain", bool "surroundfx")
{
    a.ConvertAudioToFloat()

    ## channel layouts: http://avisynth.nl/index.php/GetChannel
    ## (this is WAV 5.1)
    fl = GetChannel(1)
    fr = GetChannel(2)
    fc = GetChannel(3)
    lf = GetChannel(4)
    sl = GetChannel(5)
    sr = GetChannel(6)

    ## add center
    gc = Default(centergain, 1.0) * 0.7071
    fl = MixAudio(fl, fc, 1.0, gc)
    fr = MixAudio(fr, fc, 1.0, gc)

    ## add surround
    gs = Default(surroundgain, 1.0) * 0.7071
    fl = MixAudio(fl, sl, 1.0, gs)
    fr = MixAudio(fr, sr, 1.0, gs)

    ## cross-mix surround delayed & out-of-phase
    ## to emulate back speaker location ??
    fx = Default(surroundfx, false)
    fl = fx ? MixAudio(fl, sr.DelayAudio(0.02), 1.0, -0.7071*gs) : fl
    fr = fx ? MixAudio(fr, sl.DelayAudio(0.02), 1.0, -0.7071*gs) : fr

    MergeChannels(fl, fr)

    ## EDIT remove these from function body - add where/when needed
    #Normalize()
    #ConvertAudioTo16bit()
}

Last edited by raffriff42; 20th August 2015 at 20:22. Reason: typo: channel layout
raffriff42 is offline   Reply With Quote
Old 21st August 2015, 03:27   #14  |  Link
hello_hello
Registered User
 
Join Date: Mar 2011
Posts: 4,612
Nice. Cheers.

So if you convert to float first, can the audio still be clipped? If not, and Normalize() will prevent clipping before it's converted back to 16 bit, then I suppose there's no need for the "normalise matrix" I used. I'll have to see if I can test that later.
hello_hello is offline   Reply With Quote
Old 21st August 2015, 06:59   #15  |  Link
raffriff42
Retried Guesser
 
raffriff42's Avatar
 
Join Date: Jun 2012
Posts: 1,373
Thanks, glad you like it.

So if you convert to float first, can the audio still be clipped?
I don't think so, but I checked the source code, and I see ConvertAudioToFloat sets the maximum 16-bit range (-32768..32767) to the float range (-1..1) - so no matter how much you amplify float-format audio after conversion (within about 127 orders of magnitude, and that's a lot), clipping can *never* happen.

However, when converting float to 16-bit, values outside the range (-1..1) *will* be clipped.

Will Normalize() prevent clipping before it's converted back to 16 bit?
If I am reading this code correctly, Normalize() scales float audio to (-1..1) and integer audio to its maximum range, so clipping on conversion is prevented, assuming Normalize volume=1.0 (the default)

Last edited by raffriff42; 21st August 2015 at 07:04. Reason: typo
raffriff42 is offline   Reply With Quote
Old 22nd August 2015, 00:41   #16  |  Link
AlexKane
Registered User
 
AlexKane's Avatar
 
Join Date: Jul 2014
Posts: 20
Quote:
EDIT I'm just quoting the standard docs; if AlexKane is saying you need to adjust your mix for a particular source to make it sound right, I would not disagree.
Remixing the source should probably be avoided at all cost.

Per Dolby's spec:

Lo = Lf + C*cmixlev + Ls*surmixlev
Ro = Rf + C*cmixlev + Ls*surmixlev

...where the two variables, cmixlev & surmixlev can be adjusted in the following preset fashion: 0.707 (–3 dB), but can be adjusted to –4.5 dB or –6 dB in all decoders, and in the newest decoders can also be adjusted to off and 0 dB.

Effectively, cmixlev and surmixlev can only be assigned to one of the values mentioned above. Although you can select -1, or -5 etc it is not advisable as it would both break the operation of the DRC and alter the imaging of the content.
By breaking DRC, i mean that one would get inconsistent dynamics if DRC is engaged during the decoding stage.

I generally, doubt the whole, "adjust the center channel so you can better perceive dialogues, or drop the Lf, Rf levels to make the effects sound more tolerable and finally apply peak normalization.
If you take a look at the Film Standard (Default) DRC preset (the one we where getting during the days of DVD playback):

- Max Boost: 6 dB (below –43 dB)
- Boost Range: –43 dB to –31 dB (2:1 ratio)
- Null Zone Width: 5 dB
- Early Range: –26 dB to –16 dB (2:1 ratio)
- Cut Range: –16 dB to +4 dB (20:1 ratio)

...you will realize that this is effectively what is mixing the content to the user's environment. The level adjustments performed here are nothing to scoff at. The Cut Range alone, describes a whopping 20 dB of gain reduction, which already occurs at a whopping 35 dB above average dialogue levels.

If one wants proper/controlled dynamics in his sources (unless you are viewing movies in a theater) DRC is pretty much inevitable.
AlexKane is offline   Reply With Quote
Old 22nd August 2015, 03:29   #17  |  Link
hello_hello
Registered User
 
Join Date: Mar 2011
Posts: 4,612
Quote:
Originally Posted by raffriff42 View Post
Will Normalize() prevent clipping before it's converted back to 16 bit?
If I am reading this code correctly, Normalize() scales float audio to (-1..1) and integer audio to its maximum range, so clipping on conversion is prevented, assuming Normalize volume=1.0 (the default)
Interesting. I hadn't thought about it much until now, but I guess MeGUI always uses the matrix I posted earlier for downmixing, and adds Normalize() to the script according to whether or not normalising is checked in it's encoder configuration.

When I was downmixing a bit (back in the days of Xvid/AVI encoding) I'd often use a standard downmix matrix with enough of a volume reduction to prevent clipping (6dB to 7.5dB is usually plenty). My main motivation for doing it that way was so a group of files (ie episodes of the same TV show) would always have the same volume relative to the original. I've never been a fan of peak normalising and the volumes of files being adjusted differently as a result, although I've never had a problem with not being able to increase the volume enough on playback.
hello_hello is offline   Reply With Quote
Old 30th August 2015, 06:49   #18  |  Link
rbauer
Registered User
 
Join Date: Sep 2010
Posts: 29
@atamo
Have you tried this?
Dialogue nightmode downmix preset for 5.1 DTS to 2.0 AAC stereo using ffmpeg and qaac
it's way more simpler.
rbauer is offline   Reply With Quote
Reply

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 23:05.


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