Log in

View Full Version : 7.1 downmix function?


Pages : [1] 2

Dogway
5th August 2020, 10:59
I'm curious to know if there's some kind of 7.1 downmix function, among other I made (https://github.com/Dogway/emulation-random/blob/master/EqualizerAPO/Surround/Dolby_ProLogic_IIx_(7.1_upmix)_convo.txt) an upmixer based on DPLIIx coefficients so maybe those could be reverse engineered?

One aspect I have been wondering is in the popular DPLII downmix function negative amplitudes are being used, doesn't that imply a 180º phase instead of 90º? I think the SoxFilter can do 90º phase shift.

tebasuna51
5th August 2020, 12:41
Of course there are downmix functions and also upmix functions.

UPMIX DPLII

- Read this old thread: https://hydrogenaud.io/index.php?topic=52235.0 (I'm only interested in upmix to 5.1, 7.1 is usseless for surround 2D in my opinion)

- When you upmix never try create a LFE channel, if you want create it empty because:

All amplifier/receiver filter the low frequencies of ALL CHANNELS to sub-woofer, not only the LFE channel then the job is already make.
If you filter the low frequencies to LFE and leave them in other channels you can obtain interferences, to work properly the filter than you make and the filter than aply the receiver must be the same.
You can guarantee that for all receivers than play your upmix?
The best option LFE empty.

Of course Dolby never recommend use the LFE channel to create a downmix DPL

DOWNMIX

Seems you are talking about downmix to stereo.
In MeGUI and BeHappy (AviSynth) I recommend do the downmix 7.1 -> 5.1 to try preserve the balance between front and surround channels, and
after the plain stereo (formal or with forced coeficients to improve dialogs) or the dpl II downmix.

Of course I can make a direct 7.1 -> 2.0 if you want.

You can see also my recent UsEac3to GUI with downmix 7.1 -> 5.1 and downmix 5.1 -> 2-0 formal (you can modify coeficients) or Dpl II, using ffmpeg.
51-20v|-filter_complex "pan=stereo|FL=.3694FL+.2612FC+.3694BL+0.0LFE|FR=.3694FR+.2612FC+.3694BR+0.0LFE, volumedetect"
dplIIv|-filter_complex "pan=stereo|FL=.3254FL+.2301FC+.2818BL+.1627BR|FR=.3254FR+.2301FC-.1627BL-.2818BR, volumedetect"
71-51c|-filter_complex "asplit [f][s]; [f] pan=3.1|c0=c0|c1=c1|c2=c2|c3=c3 [r]; [s] pan=stereo|c0=0.5*c4+0.5*c6|c1=0.5*c5+0.5*c7, compand=attacks=0:decays=0:points=-90/-84|-10/-4|-6/-2|-0/-0.3, aformat=channel_layouts=stereo [d]; [r][d] amerge [a]" -map "[a]"


The full 7.1 -> dpl II can be:

-filter_complex "asplit [f][s]; [f] pan=3.1|c0=c0|c1=c1|c2=c2|c3=c3 [r]; [s] pan=stereo|c0=0.5*c4+0.5*c6|c1=0.5*c5+0.5*c7, compand=attacks=0:decays=0:points=-90/-84|-10/-4|-6/-2|-0/-0.3, aformat=channel_layouts=stereo [d]; [r][d] amerge, pan=stereo|FL=.3254FL+.2301FC+.2818BL+.1627BR|FR=.3254FR+.2301FC-.1627BL-.2818BR, volumedetect [a]" -map "[a]"

The negative coeficients are not related with 90º phase shift than must be pre-existent in surround channels with all sounds already presents in front channels.

lifta19
5th September 2020, 05:14
error:
ffmpeg.exe -threads 0 -hide_banner -y -i "input.mkv" -vn -sn -map 0:2 -filter_complex "asplit [f][s]; [f] pan=3.1|c0=c0|c1=c1|c2=c2|c3=c3 [r]; [s] pan=stereo|c0=0.5*c4+0.5*c6|c1=0.5*c5+0.5*c7, compand=attacks=0:decays=0:points=-90/-84|-10/-4|-6/-2|-0/-0.3, aformat=channel_layouts=stereo [d]; [r][d] amerge [a]" -map "[a]" -c:a ac3 -center_mixlev 0.707 -b:a 640k "output.ac3"

work fine:
ffmpeg.exe -threads 0 -hide_banner -y -i "input.mkv" -vn -sn -filter_complex "asplit [f][s]; [f] pan=3.1|c0=c0|c1=c1|c2=c2|c3=c3 [r]; [s] pan=stereo|c0=0.5*c4+0.5*c6|c1=0.5*c5+0.5*c7, compand=attacks=0:decays=0:points=-90/-84|-10/-4|-6/-2|-0/-0.3, aformat=channel_layouts=stereo [d]; [r][d] amerge [a]" -map "[a]" -c:a ac3 -center_mixlev 0.707 -b:a 640k "output.ac3"


stream map option error (-map 0:1 -map 0:2 ~~~)

tebasuna51
5th September 2020, 13:42
Without -map work fine for first audio track in container.

If you want the second audio track you can include the selection inside the -filter_complex, for instance:

ffmpeg.exe -i "input.mkv" -vn -sn -filter_complex "[0:2] asplit [f][s];..." ...

lifta19
5th September 2020, 15:21
tebasuna51 Thank you very much. Could you possibly set ffmpeg the same as Megui? Or sox remix?

request:
7.1 to 5.1, 7.1 to stereo, 5.1 to stereo

tebasuna51
5th September 2020, 17:48
The ffmpeg 'compand' filter do the same than sox with more speed. Use sox is always slow.

Also use ffmpeg is always fast than use AviSynth and the 'compand' filter do the same (more or less) than the SoftClipperFromAudX() filter used in MeGUI 32 bits.

All the request are in the second post of this thread.

The only difference with AviSynth methods is the 2 pass required (*) to emulate the AviSynth Normalize().

(*) explained in the point 2.1.5 of Readme_UsEac3to.txt attached here (https://forum.doom9.org/showthread.php?t=145574)

Selur
22nd October 2020, 14:52
@tembasuna5: I just tried to translate
-filter_complex "asplit [f][s]; [f] pan=3.1|c0=c0|c1=c1|c2=c2|c3=c3 [r]; [s] pan=stereo|c0=0.5*c4+0.5*c6|c1=0.5*c5+0.5*c7, compand=attacks=0:decays=0:points=-90/-84|-10/-4|-6/-2|-0/-0.3, aformat=channel_layouts=stereo [d]; [r][d] amerge [a]" -map "[a]"
to sox and I got the remix part
remix -m 1v1 2v1 3v1 4v1 5v0.5,7v0.6 4v0.5,8v0.5
problem is I don't get the compand part and I have no clue who to apply the compand part only on the last two channels in sox.
-> can you translate that call to sox (please)?

Cu Selur

tebasuna51
22nd October 2020, 18:02
... have no clue who to apply the compand part only on the last two channels in sox.

I have the same problem, without a command equivalent to 'asplit' I don't know how make that with sox in only one pass.

BTW, for what you need sox?
ffmpeg uses the same routines than sox and have some advantages:

1) It is much more fast than sox.

2) You can use compressed 7.1 (DTS-HD, TrueHD, EAC3, AAC) like source even without extract from some containers.

3) The output can be uncompressed (WAV, W64), lossless (FLAC, ...) or lossy (EAC3, AC3, AAC,...)

With only one pass you can extract, decode, downmix and recode to other format.

Ghitulescu
23rd October 2020, 06:13
I think only cheap x.1 amplifiers reroute ALL low signals to LFE/.1 channel, mine is set for "large speakers" (full range) and the LFE (which is active) does not work if there is no LFE channel in the signal.
I would stay for the "definition". if I would "arrange" the soundtrack. This would ensure maximum of compatibility.

tebasuna51
23rd October 2020, 11:39
@Ghitulescu
I can't understand the sense of your post. Of course amplifiers/receivers can be configured with "large speakers", I have one without subwoofer configured like this.

But, for what is related with the downmix 7.1 -> 5.1 or 2.0?

Ghitulescu
24th October 2020, 12:10
On tablet it's a PITA to quote messages. It's your first post.

I wanted to say that not all amplifiers do separate bass to send it to LFE channel. In other words, if one needs the LFE, this channel MUST exist. Stereo has no LFE, so downmixing to 2.0 should distribute the bass to bth channels. Otherwise it's safer to leave it (or create it).
Upmixing creates more channels from a less. This is what most 5.1/7.1/etc-amplifiers do with a stereo source, in particular if the combination has 5 tiny speakers and a cubic box :). Creating a fake multichannel audio in these conditions only increases the audio size - and has a deceptive efefct on the customer.
Downsizing to 2.0 is also automatically done, eg in TVs. In the long long past, when such downmix was not possible, the DVDs had 2 audios, one in 5.1 the other in 2.0. I don't even remember when I saw the last DVD with both and the last TV that couldn't downmix. Amplifiers did that for long before TVs.
In one of the sessions of AES, also published in JAES, a number of years ago, after 7.2 was launched, it was mentioned that the extra channels do not contribute essentially for the sound, so it was practically safe to discharge them from mix, in order to be played 1:1 on a 5.1 system.

tebasuna51
24th October 2020, 18:49
I wanted to say that not all amplifiers do separate bass to send it to LFE channel.

AFAIK all amplifiers/receivers can separate all bass from all channels to send to subwoofer (not LFE channel), even the cheapest 2.1 (https://www.ebay.es/itm/CASSE-TEAC-SISTEMA-2-1-2-CASSE-CON-SUBWOOFER/164463669033?hash=item264acc6f29:g:2R4AAOSw7qFe8Ej8) to connect to stereo output from PC's.

But, of course, if someone need a LFE channel is free to create it.

Selur
25th October 2020, 08:21
BTW, for what you need sox?
I do not 'need' it, but I prefer it as an alternative, since it's way easier to compile for different systems and lots of my scripts use it. :)

tebasuna51
25th October 2020, 11:47
@Selur
With intermediate files:

sox 8c341.wav front.wav remix 1 2 3 4
sox 8c341.wav surr.wav remix -m 5v0.5,7v0.5 6v0.5,8v0.5 compand 0.1,0.1 -90,-84,-16,-10,-0.1,-3 0.0 -90 0.0
sox --combine merge front.wav surr.wav down51.wav

Selur
25th October 2020, 11:58
Thanks

Richard1485
25th October 2020, 18:01
I prefer Sox as well because it's not been updated in so long that you can pretty much guarantee that you'll be dealing with the same version and be assured of consistent behavior, whereas ffmpeg changes, and Linux distros ship with different versions.


sox 8c341.wav front.wav remix 1 2 3 4


This works perfectly.


sox 8c341.wav surr.wav remix -m 5v0.5,7v0.5 6v0.5,8v0.5 compand 0.1,0.1 -90,-84,-16,-10,-0.1,-3 0.0 -90 0.0


At this stage, I receive a warning.


sox WARN compand: compand clipped 1898 samples; decrease volume?
sox WARN sox: `surr.wav' output clipped 911 samples; decrease volume?


My source file is w64, rather than wav, but that shouldn't matter.

tebasuna51
25th October 2020, 21:57
At this stage, I receive a warning.

The compand function is not perfect.
Try other values decreasing the gain slowly, for instance:

-90,-84,-10,-4,-6,-2,-0,-1

In theory that means: gain 6 dB for input less than -10 dB, decrease the gain until 4 dB when reach input -6 dB, and decrease the gain until attenuate -1dB at max value 0 dB

But some transients because attacks/decays can cause some clip without importance.

Richard1485
25th October 2020, 23:40
Try other values decreasing the gain slowly, for instance:

-90,-84,-10,-4,-6,-2,-0,-1

I don't understand. Do I replace


sox 8c341.wav surr.wav remix -m 5v0.5,7v0.5 6v0.5,8v0.5 compand 0.1,0.1 -90,-84,-16,-10,-0.1,-3 0.0 -90 0.0

with


sox 8c341.wav surr.wav remix -m 5v0.5,7v0.5 6v0.5,8v0.5 compand 0.1,0.1 -90,-84,-10,-4,-6,-2,-0,-1


and retry? The result seems to be more clipping:


sox WARN compand: compand clipped 3058 samples; decrease volume?
sox WARN sox: `surr.wav' output clipped 1400 samples; decrease volume?


But maybe because you say "without importance", I could have ignored the warning in the first place.

tebasuna51
26th October 2020, 14:12
See the attached image to understand how work the dB points in compand, to obtain a gain of 2 (preserving the full volume of 4 channels in only 2 speakers) with low/medium volume input.

Like you can see is not possible the clip, out of transient volumes because attack/decay values. Use attack/decay values of 0.0 to avoid any clip.

See more info about attack/decay, for instance here (http://underpop.online.fr/f/ffmpeg/help/compand.htm.gz).

EDIT: added a second compand option.
Each user can select the desired.

Richard1485
27th October 2020, 02:59
Thanks! I'll take the second option.

hello_hello
28th October 2020, 19:21
The ffmpeg 'compand' filter do the same than sox with more speed. Use sox is always slow.

Also use ffmpeg is always fast than use AviSynth and the 'compand' filter do the same (more or less) than the SoftClipperFromAudX() filter used in MeGUI 32 bits.

Is it the SoftClipperFromAudX() filter that's incredibly slow?

I tried downmixing a less than 5 minute 7.1ch wave file to stereo with MeGUI while converting to flac, and after indexing it took roughly one minute to complete. I didn't normalize.

To do the same thing with foobar2000 I downmix 7.1ch to 5.1ch with the Matrix Mixer, run that through the Amplify DSP to increase the volume by a couple of dB (for the next DSP), then through fb2k's Advanced Limiter to limit any loud peaks after combining the surround channels, from there it goes through the Amplify DSP again to reduce the volume by 2dB before being downmixed to stereo with the Matrix Mixer DSP.
For the same file, outputting flac once more, that whole process took about 4 seconds.

tebasuna51
29th October 2020, 02:01
Is not only SoftClipperFromAudX(), is AviSynth 32 bits, use ffmpeg instead.

PatchWorKs
2nd November 2020, 09:53
Hi there, can you finally "sum up" all the (proper ?) ways to downmix multichannels to stereo with FFMPEG ?

I've already cheked many approaches, but I'm a bit confused now...
- https://superuser.com/questions/852400/properly-downmix-5-1-to-stereo-using-ffmpeg
- http://forum.doom9.org/showthread.php?t=168267

Thanks in advance.

tebasuna51
2nd November 2020, 12:55
...can you finally "sum up" all the (proper ?) ways to downmix multichannels to stereo with FFMPEG ?

1) If your input is 7.1, first do a 7.1 -> 5.1 downmix with the compand selected (see precedent posts):
-filter_complex "asplit [f][s]; [f] pan=3.1|c0=c0|c1=c1|c2=c2|c3=c3 [r]; [s] pan=stereo|c0=0.5*c4+0.5*c6|c1=0.5*c5+0.5*c7, compand=attacks=0:decays=0:points=-90/-84|-8/-2|-6/-1|-0/-0.1, aformat=channel_layouts=stereo [d]; [r][d] amerge [a]" -map "[a]"

2) If your audio equipment support Dolby ProLogic decoder (recover a 5.0 from your 2.0 file) use the DPLII downmix:
-filter_complex "pan=stereo|FL=.3254FL+.2301FC+.2818BL+.1627BR|FR=.3254FR+.2301FC-.1627BL-.2818BR"

3) If your audio equipment is only stereo (TV for instance) does not exist a proper way, because is not possible suply the same audio volume with 2 speakers than with 5 speakers, and there are many options. Select the desired:

a) The formal approach to preserve the balance between all the channels (of course the LFE channel is ignored by Dolby recommendation):
-filter_complex "pan=stereo|FL=.3694FL+.2612FC+.3694BL+0.0LFE|FR=.3694FR+.2612FC+.3694BR+0.0LFE, volumedetect"

b) The extreme dialog maximize:
-filter_complex "pan=stereo|FL=.5FL+.5FC+.0BL+0.0LFE|FR=.5FR+.5FC+.0BR+0.0LFE, volumedetect"

c) Any option between a) and b). The coeficients for each channel must sum 1 to avoid clip. For instance:
-filter_complex "pan=stereo|FL=.5FL+.4FC+.1BL+0.0LFE|FR=.5FR+.4FC+.1BR+0.0LFE, volumedetect"

I include the volumedetect filter to see if the mix admit a gain without clip.

Mix like:
FL=FC+0.30*FL+0.30*BL (sum of coeficients 1.6)
FL=0.5*FC+0.707*FL+0.707*BL+0.5*LFE (sum of coeficients 2.414)
are wrong because can produce clips.

Mix like (see the < instead the =)
FL < 1.0*FL + 0.707*FC + 0.707*BL
are equivalent (automatic normalization):
FL = 0.414*FL + 0.293*FC + 0.293*BL

PatchWorKs
6th November 2020, 10:12
Mix like (see the < instead the =)
FL < 1.0*FL + 0.707*FC + 0.707*BL
are equivalent (automatic normalization):
FL = 0.414*FL + 0.293*FC + 0.293*BL
Is this the implementation of "Novel 5.1 Downmix Algorithm with Improved Dialogue Intelligibility (https://www.researchgate.net/publication/237098997_Novel_51_Downmix_Algorithm_with_Improved_Dialogue_Intelligibility)" research ?

https://i31.servimg.com/u/f31/16/32/04/85/ndmix10.png

Similar to the state-of-the-art downmix methods, only 5 channels are taken into consideration: L, R, C, Ls and Rs. We can represent the downmix operation in the form of the following equation:

lt [n] = l[n] + 0.707 * c[n] + (dlev - 1) * e[n] + 0.5 * ls [n]
rt [n] = r[n] + 0.707 * c[n] + (dlev - 1) * e[n] + 0.5 * rs [n]

where e[n] is the extracted voice signal, dlev represents the dialogue level and all considered signals are represented in the digital domain, in which n denotes the sample index.

Someone @ Hydrogenaudio forums (https://hydrogenaud.io/index.php?topic=55442.0) implemented it in this way:
ffmpeg -i 6chan-input.wav -af "pan=stereo|FL < 1.0*FL + 0.707*FC + 0.707*BL|FR < 1.0*FR + 0.707*FC + 0.707*BR" -ac copy stereo.wav

...do you think is correct (and proper) ?

tebasuna51
6th November 2020, 21:42
Is this the implementation of "Novel 5.1 Downmix Algorithm with Improved Dialogue Intelligibility (https://www.researchgate.net/publication/237098997_Novel_51_Downmix_Algorithm_with_Improved_Dialogue_Intelligibility)" research ?

Nope. I don't know algoritms to implement "Disparity analysis" or "Voice channel extraction"

Someone @ Hydrogenaudio forums (https://hydrogenaud.io/index.php?topic=55442.0) implemented it in this way:
...do you think is correct (and proper) ?

Is a option included in my c) option.
Can work fine for some sources but bad for others (low dialogs).
I prefer a C coeficient greater than the B coeficients.

richardpl
6th November 2020, 23:36
For low dialogs, use dynamic range compressor.

PatchWorKs
7th November 2020, 08:23
Nope. I don't know algoritms to implement "Disparity analysis" or "Voice channel extraction"
It's deeply described at pages 4-5-6 of the research PDF (https://www.researchgate.net/profile/Bartosz_Kunka/publication/237098997_Novel_51_Downmix_Algorithm_with_Improved_Dialogue_Intelligibility/links/0c96051b81c8e4b061000000/Novel-51-Downmix-Algorithm-with-Improved-Dialogue-Intelligibility.pdf)...

...do you think it's implementable in FFMPEG ?

tebasuna51
7th November 2020, 12:05
AFAIK the mix suggested is (for each stereo channel):

lt [n] = l[n] + 0.707 * c[n] + (dlev - 1) * e[n] + 0.5 * ls [n]

with e[n] the extra channel provided by the "Voice channel extraction", and the suggested boost for it is 10 dB (dlev = 3.216). Then can be:

FL < 1FL + 0.707FC + 2.162E + 0.5BL

and normalized:

FL = 0.229FL + 0.162FC + 0.495E + 0.114BL

I don't know how extract the E (Voice channel extraction) channel with ffmpeg functions, but seems than the stereo channels have more than half of the volume to only voices, for me is too much.

We can obtain the same voice volume (not so clear) with:

FL = 0.229FL + 0.657FC + 0.114BL

For me FL=.5FL+.4FC+.1BL is more than enough preserving the stereo effect much more.

PatchWorKs
9th November 2020, 12:39
For me FL=.5FL+.4FC+.1BL is more than enough preserving the stereo effect much more.

...you mean your previous "c" option:
-filter_complex "pan=stereo|FL=.5FL+.4FC+.1BL+0.0LFE|FR=.5FR+.4FC+.1BR+0.0LFE, volumedetect"

So, in the end, adding "<" instead of "=" (as you suggested) should be the best multichannel to stereo downmix by FFMPEG, right ?
-filter_complex "pan=stereo|FL<.5FL+.4FC+.1BL+0.0LFE|FR<.5FR+.4FC+.1BR+0.0LFE, volumedetect"

richardpl
9th November 2020, 13:10
...you mean your previous "c" option:
-filter_complex "pan=stereo|FL=.5FL+.4FC+.1BL+0.0LFE|FR=.5FR+.4FC+.1BR+0.0LFE, volumedetect"

So, in the end, adding "<" instead of "=" (as you suggested) should be the best multichannel to stereo downmix by FFMPEG, right ?
-filter_complex "pan=stereo|FL<.5FL+.4FC+.1BL+0.0LFE|FR<.5FR+.4FC+.1BR+0.0LFE, volumedetect"

NO.

FFmpeg have many options for downmix.

tebasuna51
9th November 2020, 14:36
So, in the end, adding "<" instead of "=" (as you suggested)

Put < or = when the sum of coeficients is 1 (.5 + .4 + .1 = 1) is the same mix.
should be the best multichannel to stereo downmix by FFMPEG, right ?

I can't say that. It can change with different sources, users preferences and device player.

PatchWorKs
11th November 2020, 08:34
Ok, last question: does this formula "correctly" downmix 7.1/atmos to stereo ?

-filter_complex "asplit [f][s]; [f] pan=3.1|c0=c0|c1=c1|c2=c2|c3=c3 [r]; [s] pan=stereo|c0=0.5*c4+0.5*c6|c1=0.5*c5+0.5*c7, compand=attacks=0:decays=0oints=-90/-84|-10/-4|-6/-2|-0/-0.3, aformat=channel_layouts=stereo [d]; [r][d] amerge, pan=stereo|FL=.3254FL+.2301FC+.2818BL+.1627BR|FR=.3254FR+.2301FC-.1627BL-.2818BR, volumedetect [a]" -map "[a]"

Thanks.

tebasuna51
11th November 2020, 11:55
Warning with the emoticon. Must be:
-filter_complex "asplit [f][s]; [f] pan=3.1|c0=c0|c1=c1|c2=c2|c3=c3 [r]; [s] pan=stereo|c0=0.5*c4+0.5*c6|c1=0.5*c5+0.5*c7, compand=attacks=0:decays=0:points=-90/-84|-10/-4|-6/-2|-0/-0.3, aformat=channel_layouts=stereo [d]; [r][d] amerge, pan=stereo|FL=.3254FL+.2301FC+.2818BL+.1627BR|FR=.3254FR+.2301FC-.1627BL-.2818BR, volumedetect [a]" -map "[a]"

And this is a Dolby Prologic downmix to be played with audio equipment with DplII decoder.

To be played for a stereo only audio equipment (TV for instance) maybe you can try other downmix:
-filter_complex "asplit [f][s]; [f] pan=3.1|c0=c0|c1=c1|c2=c2|c3=c3 [r]; [s] pan=stereo|c0=0.5*c4+0.5*c6|c1=0.5*c5+0.5*c7, compand=attacks=0:decays=0:points=-90/-84|-8/-2|-6/-1|-0/-0.1, aformat=channel_layouts=stereo [d]; [r][d] amerge, pan=stereo|FL=.4FL+.4FC+.2BL|FR=.4FR+.4FC+.2BR, volumedetect [a]" -map "[a]"
Now with the compand curve (for 7.1 -> 5.1) preferred by Richard1485:
points=-90/-84|-8/-2|-6/-1|-0/-0.1
and a mix stereo (not dplII) with the dialogs reinforced:
pan=stereo|FL=.4FL+.4FC+.2BL|FR=.4FR+.4FC+.2BR

Does not exist a unique correct way to do the downmix because depend on:
- Device player (with or without DplII)
- Kind of source (it need or not reinforce dialogs)
- Users preferences (dialogs, compand curve)

SeeMoreDigital
11th November 2020, 16:22
And this is a Dolby Prologic downmix to be played with audio equipment with DplII decoder...I have a few Dolby Surround (Prologic) encoded CD's. It would be interesting if such CD's could be reverse encoded to create native surround-sound channels.

tebasuna51
11th November 2020, 23:41
The best option I know is the Foobar2000 plugin FreeSurround (https://hydrogenaud.io/index.php/topic,52235.0.html) configured like the attached image.

Maybe the PowerDVD compatibility (a inverted surround channel) is better, that change with the method used to construct the dpl encode (it can't be know).

There are a ffmpeg function but for me is worse, maybe I don't found the correct parameters, this is my best test:

-af "surround=lfe_out=0:level_out=2"

damian101
2nd February 2022, 03:52
I use this one for all downmixing to stereo: -af 'lowpass=c=LFE:f=120,pan=stereo|FL=.3FL+.21FC+.3FLC+.3SL+.3BL+.21BC+.21LFE|FR=.3FR+.21FC+.3FRC+.3SR+.3BR+.21BC+.21LFE'

Works for various channel configurations, including standard 7.1, 6.1, 5.1.

I usually normalize as well, by doing a first run with ebur128 at the end of the filter chain, and then setting a dB offset with volume filter in the actual encode, to reach -23 LUFS.

tebasuna51
2nd February 2022, 11:55
I use this one for all downmixing to stereo:

Like I say already each user is free to experiment and select the preferred method.

But for me there are some troubles:

- Dolby recommend don't use the LFE channel in the downmix (and worse filtered), because can cancel or distort low frequencies present in other channels.

- The volume of FC channel (.21) is very low compared with the rest of channels (1.2) and the dialogs can be inaudibles.

- I can't recommend use double volume of front channels (.3) for surround channels (.6)

Maybe...
-af 'pan=stereo|FL=.4FL+.3FC+.15FLC+.15SL+.15BL+.15BC|FR=.4FR+.3FC+.15FRC+.15SR+.15BR+.15BC'

PatchWorKs
27th September 2022, 18:23
Sorry to revive this old 3ad but the bet is still kicking...

...just found this interesting reply (https://superuser.com/a/1739011) - dated Aug 25 - from PierU @ Super User (https://superuser.com/users/1691411/pieru):


Old question but still interesting to me...

First, I never encountered a global volume issue. After reading the answer from @Franz-Michael Fisher I made a few tests, starting from a file with a DTS 5.1 track and transcoding it to pcm_s16le, pcm_f32le, and aac, all of them with the -ac 2 option. When playing the files with VLC and headphones, all of them sound the same as the original, except the pcm_s16le one that sounds quieter. Since I always use aac, the global volume is apparently not an issue.

Second, I sometimes face the problem of too low perceived dialogs compared to the music/sounds. So it's indeed tempting to downmix with alternate formulas that give more weight to the central channel FC, and I did that for a while... However, it turns out that FC does not contain only voices but also a large part of the music and sounds: as a consequence, overweighting FC is also narrowing the stereo image, which is not desirable...

I kept wondering why the dialogs are sometimes perceived too low after downmixing, and I have a possible explanation: the brain is very good at isolating a voice buried in the ambient noise according to the direction it comes from. That's why people with hearing aids still have difficulties to follow a conversation when multiple people speak at the same time: the earings aids can restore the volume, but the directivity is lost... So, with a real 5.1 or 7.1 setup the brain is not bothered by the side/rear channels when it comes to focus on the dialog, because they come from fully different directions. After downmix this is not the same: what was coming from the side/rear channels is now coming from the front, making the separation task more difficult for the brain. The solution is hence to downweight the side/rear channels: instead of the ATSC formula

-af "pan=stereo|FL < 1.0*FL + 0.707*FC + 0.707*BL|FR < 1.0*FR + 0.707*FC + 0.707*BR"

I am now using

-af "pan=stereo|FL < 1.0*FL + 0.707*FC + 0.4*BL|FR < 1.0*FR + 0.707*FC + 0.4*BR"


...it is a correct argue ?

tebasuna51
28th September 2022, 09:45
...it is a correct argue ?

Yes, it is correct for me.

But remember, the thread is about 7.1 downmix and this downmix is for a 5.1 downmix and the canonical downmix is:
pan=stereo|FL=.37FL+.26FC+.37BL|FR=.37FR+.26FC+.37BR
with very low FC presence

And the suggested:

pan=stereo|FL < 1.0*FL + 0.707*FC + 0.707*BL|FR < 1.0*FR + 0.707*FC + 0.707*BR
Is the same than (with = instead <, and rounding)
pan=stereo|FL=.4FL+.3FC+.3BL|FR=.4FR+.3FC+.3BR

And myself I suggested (five post before) a mix with more FC presence:
pan=stereo|FL=.4FL+.4FC+.2BL|FR=.4FR+.4FC+.2BR

The other:
pan=stereo|FL < 1.0*FL + 0.707*FC + 0.4*BL|FR < 1.0*FR + 0.707*FC + 0.4*BR
same than:
pan=stereo|FL=.47FL+.33FC+.19BL|FR=.47FR+.33FC+.19BR
have fronts with more force, I don't know if it is better.
Is a question of taste.

tormento
8th November 2022, 10:41
Of course there are downmix functions and also upmix functions.
Did you ever try to understand how good is DEE downmix function?

tebasuna51
8th November 2022, 12:46
DEE ddp Downmix

7.1 -> 5.1 Something like:

FL' = 0.54*FL
FR' = 0.57*FR
FC' = 0.64*FC
LF' = 1.00*LF
SL' = 0.4*SL + 0.4*BL
SR' = 0.4*SR + 0.4*BR

7.1 -> 2.0 Something like:

FL' = 0.54*FL + 0.45*FC + 0.34*SL + 0.33*BL [1.66 clip risk]
FR' = 0.48*FR + 0.45*FC + 0.30*SR + 0.34*BR [1.57 clip risk]

5.1 -> 2.0 Something like:

FL' = 0.54*FL + 0.38*FC + 0.47*SL [1.39 clip risk]
FR' = 0.48*FR + 0.38*FC + 0.46*SR [1.32 clip risk]

pandy
30th November 2022, 21:34
This triggered my curiosity - isn't feasible to use SOFA filter https://ffmpeg.org/ffmpeg-filters.html#sofalizer to downmix 7.1 (up to 9 channels) to 2 channel? Of course some synthetic SOFA file can be used if HRTF is unwanted.

richardpl
1st December 2022, 00:46
Can use headphone filter, and also afir filter in casea impulse response files are really big.

tebasuna51
4th February 2023, 17:28
1) If your input is 7.1, first do a 7.1 -> 5.1 downmix with the compand selected (see precedent posts):
-filter_complex "asplit [f][s]; [f] pan=3.1|c0=c0|c1=c1|c2=c2|c3=c3 [r]; [s] pan=stereo|c0=0.5*c4+0.5*c6|c1=0.5*c5+0.5*c7, compand=attacks=0:decays=0:points=-90/-84|-8/-2|-6/-1|-0/-0.1, aformat=channel_layouts=stereo [d]; [r][d] amerge [a]" -map "[a]"

WARNING: when use these filters with a recent ffmpeg v5.1 there are a regression detected. (https://trac.ffmpeg.org/ticket/10168)

Use a ffmpeg v4.4 until the regression was solved.

tebasuna51
9th February 2023, 23:34
The regression detected (https://trac.ffmpeg.org/ticket/10168) is not fixed.

I open a new one (https://trac.ffmpeg.org/ticket/10180)

Selur
11th February 2023, 16:10
The regression detected (https://trac.ffmpeg.org/ticket/10168) is not fixed.

Confused, according to your link:

Status: new → closed

Fixed in 93a9ee7afd7bf2e019490117f1bada30724a0200 (http://git.videolan.org/?p=ffmpeg.git;a=commitdiff;h=93a9ee7afd7bf2e019490117f1bada30724a0200)

tebasuna51
12th February 2023, 12:55
It is not fixed, now do other remix unwanted, see the image in the new one.

Balling
19th February 2023, 22:43
It is not fixed, now do other remix unwanted, see the image in the new one.

Fixed now.

tebasuna51
21st February 2023, 12:39
I test the Latest Auto-Build (2023-02-20 12:35) in https://github.com/BtbN/FFmpeg-Builds/releases
Seems work correctly now:

1) 7.1 -> 5.1 downmix with the compand selected (see precedent posts):
-filter_complex "asplit [f][s]; [f] pan=3.1|c0=c0|c1=c1|c2=c2|c3=c3 [r]; [s] pan=stereo|c0=0.5*c4+0.5*c6|c1=0.5*c5+0.5*c7, compand=attacks=0:decays=0:points=-90/-84|-8/-2|-6/-1|-0/-0.1, aformat=channel_layouts=stereo [d]; [r][d] amerge [a]" -map "[a]"

There are two 'green messages':
[Parsed_pan_1 @ 000001fc795c1d80] Pure channel mapping detected: 0 1 2 3
It always appears no matter what I use:
pan=3.1|c0=c0|c1=c1|c2=c2|c3=c3
until
pan=FL+FR+FC+LFE|FL=FL|FR=FR|FC=FC|LFE=LFE

And
[Parsed_amerge_5 @ 000002ac9b81ce00] Input channel layouts overlap: output layout will be determined by the number of distinct input channels
But any attempt to specify the correct channel layout for the surround channels, instead 'stereo', like:
pan=SL+SR...,compand...
or
aformat=channel_layouts=SL+SR
abort the process.

2) I suggest use for 6.1 -> 5.1 downmix:

-filter_complex "asplit [f][s]; [f] pan=3.1|c0=c0|c1=c1|c2=c2|c3=c3 [r]; [s] pan=stereo|c0=0.412*c4+0.588*c5|c1=0.412*c4+0.588*c6, compand=attacks=0:decays=0:points=-90/-85.4|-8/-3.4|-5/-1|-0/-0.1, aformat=channel_layouts=stereo [d]; [r][d] amerge [z]" -map "[z]"