View Full Version : Upmix of center back channel in 4.0 to BL/BR in 5.0


Sakura-chan
26th September 2026, 08:04
I have some 4.0 tracks with the non-standard layout of FL FR FC BC. I need to map that back center channel to the more typical home setup of 5.1/7.1, that is upmix it into the surround channels.

I'm not good with ffmpeg so to test I made 4 mono tracks with 30 sec of silence plus 10 sec of random music (same music segment at the same volume) at different intervals. FL plays from 0-10s, FR 10-20s, FC 20-30s and BC 30-40s.

Btw, I only have stereo speakers/headphones to try the result.

First I went with this:

ffmpeg -i FL.wav -i FR.wav -i FC.wav -i BC.wav -filter_complex "[0:a][1:a][2:a][3:a]join=inputs=4:channel_layout=5.0:map=0.0-FL|1.0-FR|2.0-FC|3.0-BL|3.0-BR[a]" -map "[a]" -acodec pcm_s16le join.wav

It worked but the 30-40s segment was too loud. Ofc, the same segment now from two speakers ends up louder. On the other hand the player knows what it's doing and when outputting the center channel to both speakers it lowers the volume somewhat, so it doesn't overpower FL and FR.

So, apparently the pan filter is what I need, like this:

ffmpeg -i FL.wav -i FR.wav -i FC.wav -i BC.wav -filter_complex "[0:a][1:a][2:a][3:a]amerge=inputs=4,pan=5.0|FL=c0|FR=c1|FC=c2|BL=0.5*c3|BR=0.5*c3[a]" -map "[a]" -acodec pcm_s16le output.wav

Logically you multiply the back channel by 0.5, so both together end up at 1. But now they are too low. It seems 0.7 does the trick, making the 4 segments sound at equal levels (as far as I can hear). I'm trying with two players, PotPlayer and foobar.

Am I doing something wrong? Something to improve in the ffmpeg command? The second one gives me a warning but everything seems to work:
[aist#0:0/pcm_s16le @ 000001b9a7a54340] Guessed Channel Layout: mono
Input #0, wav, from 'FL.wav':
Duration: 00:00:40.00, bitrate: 768 kb/s
Stream #0:0: Audio: pcm_s16le ([1][0][0][0] / 0x0001), 48000 Hz, mono, s16, 768 kb/s
[aist#1:0/pcm_s16le @ 000001b9a7a7b840] Guessed Channel Layout: mono
Input #1, wav, from 'FR.wav':
Duration: 00:00:40.00, bitrate: 768 kb/s
Stream #1:0: Audio: pcm_s16le ([1][0][0][0] / 0x0001), 48000 Hz, mono, s16, 768 kb/s
[aist#2:0/pcm_s16le @ 000001b9a7a67900] Guessed Channel Layout: mono
Input #2, wav, from 'FC.wav':
Duration: 00:00:40.00, bitrate: 768 kb/s
Stream #2:0: Audio: pcm_s16le ([1][0][0][0] / 0x0001), 48000 Hz, mono, s16, 768 kb/s
[aist#3:0/pcm_s16le @ 000001b9a96c31c0] Guessed Channel Layout: mono
Input #3, wav, from 'BC.wav':
Duration: 00:00:40.00, bitrate: 768 kb/s
Stream #3:0: Audio: pcm_s16le ([1][0][0][0] / 0x0001), 48000 Hz, mono, s16, 768 kb/s
Stream mapping:
Stream #0:0 (pcm_s16le) -> amerge
Stream #1:0 (pcm_s16le) -> amerge
Stream #2:0 (pcm_s16le) -> amerge
Stream #3:0 (pcm_s16le) -> amerge
pan:default -> Stream #0:0 (pcm_s16le)
Press [q] to stop, [?] for help
[Parsed_amerge_0 @ 000001b9a97a6180] No channel layout for input 1
[Parsed_amerge_0 @ 000001b9a97a6180] Input channel layouts overlap: output layout will be determined by the number of distinct input channels
Output #0, wav, to 'output.wav':
Metadata:
ISFT : Lavf63.1.102
Stream #0:0: Audio: pcm_s16le ([1][0][0][0] / 0x0001), 48000 Hz, 5.0, s16, 3840 kb/s
Metadata:
encoder : Lavc63.1.102 pcm_s16le
[out#0/wav @ 000001b9a79dcb40] video:0KiB audio:18750KiB subtitle:0KiB other streams:0KiB global headers:0KiB muxing overhead: 0.000531%
size= 18750KiB time=00:00:40.00 bitrate=3840.0kbits/s speed= 902x elapsed=0:00:00.04

What's the magic number to mix the channels at? Or just trial and error for each track?

hello_hello
26th September 2026, 15:07
When a front center channel is duplicated into the front stereo channels for downmixing, it's fairly standard to reduce the volume of the center channel by 3dB, so I assume the same would apply to BC and BL/BR. From memory, two speakers producing the same sound at the same volume increases the volume by 3dB compared to a single speaker, hence the 3dB reduction. Or something like that. -3dB = 70.7%.
https://calculator.academy/db-to-percentage-calculator/

Until someone good with ffmpeg filters comes along (I'm not)...
As you use foobar2000, you could try adding the Matrix Mixer DSP to the conversion chain. Or adding it to the playback chain for testing. I don't think it's in the official list of DSPs for some reason, but you can download it here and it works well. It only comes in a 32 bit flavour though.
https://www.softpedia.com/get/Multimedia/Audio/Audio-Plugins/foo-dsp-mm.shtml

I used it to put one channel from a stereo source into FL FR FC BC to simulate your 4ch source files, but of course you won't need to do that, then I added a second instance of the Matrix Mixer to the DSP chain to convert that to 5.0ch.
So as long as your files are decoded to the correct channels it should be easy enough to add the Matrix Mixer to the conversion chain and convert them.... although if they're not for some reason you could always use the Matrix Mixer to correct that.

Simulate 4ch.png (https://files.videohelp.com/u/210984/Simulate%204ch.png)
Convert 4ch to 5.0.png (https://files.videohelp.com/u/210984/Convert%204ch%20to%205.0.png)
Foobar Output.png (https://files.videohelp.com/u/210984/Foobar%20Output.png)

raquete
26th September 2026, 20:52
Very complicated for me but i could understand looking the images.

hello_hello,
what you do in foobar to show the peaks in vertical?

Is secure download and install Db ↔ Percentage Calculator?

hello_hello
26th September 2026, 23:04
The output meter is a standard FB2K GUI element. You can add it to the default interface, or you can run it separately via the View/Visualizations/Peak Meter menu. It mightn't always be vertical though, but if you decrease the width or increase the height of the Peak Meter window it'll switch to vertical when the ratio is right. You can run it full screen by right clicking on it too. It only displays the number of channels in the output, and that changes automatically, so for a stereo source you'd only see FL & FR.

The dB to percentage calculator is online. It's just a web page. Nothing to download. There's two different formulas for the conversion explained on the page, but it's the Amplitude conversion that applies in this case.

PS. There's a portable version of FB2K I uploaded a while ago here (https://forum.videohelp.com/threads/396860-foobar2000-portable-%28for-audio-encoding%29). You can just unzip it somewhere and run it. There's also another zip file with a bunch of encoders included. Everything you'll likely ever need. The encoders folder has to be saved to a specific location for many of the conversion presets to work. There's info in the post I linked to. The matrix mixer is included. It's a 32 bit version of FB2K but if you're running a 64 bit version of windows you can use the 64 bit encoders.

tebasuna51
27th September 2026, 11:03
Audio volume is proportional to the square of the electrical volume; therefore, the surround channels must be generated as follows:
SL = 0.7071*BC
SR = 0.7071*BC

Thus, the sound power of SL+SR is equivalent to BC.
SL^2 + SR^2 = (0.7071*BC)^2 + (0.7071*BC)^2 = 0.5*BC^2 + 0.5*BC^2= BC^2

It is not necessary to extract the channels beforehand; it is simpler to use the original as the source:

ffmpeg -i FL_FR_FC_BC.wav -af "pan=5.1|c0=c0|c1=c1|c2=c2|c3=0.0*c3|c4=0.7071*c3|c5=0.7071*c3" -acodec pcm_s24le output.wav

Where:
FL_FR_FC_BC.wav can be in other codec supported by ffmpeg
final c3 is the LFE channel recommended empty
The output can be any format supported by ffmpeg, if wav preserve the quality (at least s24le) until final encode.

raquete
27th September 2026, 12:58
@hello_hello

All hints for foobar are working perfectly and the portable version of FB2K you uploaded :thanks:

About the percentage calculator
Last Updated: July 14, 2026

after you do 2 'calculations' appear one kind of pop-up:
"Install the app Calculator Pro (calculator accademy...etc"

It's free?

hello_hello
27th September 2026, 20:27
I haven't seen that popup. I assume my ad blocker must be zapping it.
Sorry, I didn't realise there was one, so to answer your question, I have no idea. :(

Sakura-chan
29th September 2026, 07:15
When a front center channel is duplicated into the front stereo channels for downmixing, it's fairly standard to reduce the volume of the center channel by 3dB, so I assume the same would apply to BC and BL/BR. From memory, two speakers producing the same sound at the same volume increases the volume by 3dB compared to a single speaker, hence the 3dB reduction. Or something like that. -3dB = 70.7%.
https://calculator.academy/db-to-percentage-calculator/

Until someone good with ffmpeg filters comes along (I'm not)...
As you use foobar2000, you could try adding the Matrix Mixer DSP to the conversion chain. Or adding it to the playback chain for testing. I don't think it's in the official list of DSPs for some reason, but you can download it here and it works well. It only comes in a 32 bit flavour though.
https://www.softpedia.com/get/Multimedia/Audio/Audio-Plugins/foo-dsp-mm.shtml

I used it to put one channel from a stereo source into FL FR FC BC to simulate your 4ch source files, but of course you won't need to do that, then I added a second instance of the Matrix Mixer to the DSP chain to convert that to 5.0ch.
So as long as your files are decoded to the correct channels it should be easy enough to add the Matrix Mixer to the conversion chain and convert them.... although if they're not for some reason you could always use the Matrix Mixer to correct that.

Simulate 4ch.png (https://files.videohelp.com/u/210984/Simulate%204ch.png)
Convert 4ch to 5.0.png (https://files.videohelp.com/u/210984/Convert%204ch%20to%205.0.png)
Foobar Output.png (https://files.videohelp.com/u/210984/Foobar%20Output.png)
So the 0.7 I eyeballed (earballed more like) was essentially correct. I think I've seen the 3dB somewhere but was not sure how to convert it to the multiplier required by the pan filter. Turns out there was a simple calculator. I was using foobar just to listen how loud the channels sounded when feeding it a multichannel track and let it downmix. It works well without DSPs. For converting I just use ffmpeg. Btw, here's a post mentioning the 0.7 too: https://forum.doom9.org/showthread.php?p=1933417#post1933417

Audio volume is proportional to the square of the electrical volume; therefore, the surround channels must be generated as follows:
SL = 0.7071*BC
SR = 0.7071*BC

Thus, the sound power of SL+SR is equivalent to BC.
SL^2 + SR^2 = (0.7071*BC)^2 + (0.7071*BC)^2 = 0.5*BC^2 + 0.5*BC^2= BC^2

It is not necessary to extract the channels beforehand; it is simpler to use the original as the source:

ffmpeg -i FL_FR_FC_BC.wav -af "pan=5.1|c0=c0|c1=c1|c2=c2|c3=0.0*c3|c4=0.7071*c3|c5=0.7071*c3" -acodec pcm_s24le output.wav

Where:
FL_FR_FC_BC.wav can be in other codec supported by ffmpeg
final c3 is the LFE channel recommended empty
The output can be any format supported by ffmpeg, if wav preserve the quality (at least s24le) until final encode.
Perfect. So those are the exact values. Yes, I was doing an unnecessary first step of splitting the channels. Thank you for the help.

I can also ignore the LFE and keep the track as 5.0 I guess. 5.0 is a typical layout that just works.

The reason for all this is that players don't seem to be respecting the WAVEFORMATEXTENSIBLE_CHANNEL_MASK tag in opus files. They ignore it and a 4.0 opus (FL FR FC BC) plays as "quad" (FR FL BL BR). mkvmerge doesn't write the tag while muxing either and the layout is lost. Flac works the same way with non-typical channel layouts, with the same channel_mask tag, but players read it, mkvmerge writes it and everything is fine. At any rate home setups are typically 2.0, 5.1 or 7.1 so a single center back channel is going to get upmixed in 99% of the cases, losing it by upmixing manually isn't going to hurt. Btw, 5.0 is a "typical" flac/opus layout, so no tag is needed and no compatibility issues.

Well, this settles it. Thank you all for the input.