I'm using the "-ac 2" parameter in ffmpeg to downmix 8 channel audio to stereo.
Both the 8 channel audio, and the downmixed 2 channel audio, have the same maximum amplitude of 0.0 dB. But the 8 channel audio sounds significantly louder than the downmixed stereo audio, when played back with PotPlayer with the PotPlayer's volume slider set to 100%.
Does this mean that PotPlayer does downmixing better than "ffmpeg -ac 2"? Is "ffmpeg -ac 2" the best way to downmix, or is there a better way than this? Is SoX better at downmixing than ffmpeg?
+ Reply to Thread
Results 1 to 11 of 11
-
Last edited by codemaster; 12th Dec 2023 at 11:36.
-
There is many information about correct downmix for 5.1 to sterero, g.e.
https://superuser.com/questions/852400/properly-downmix-5-1-to-stereo-using-ffmpeg
Read this and make some tests for 8ch to 2ch. -
I want to use Dave_750's downmix formula instead of "-ac 2", but I can't because it's for 5.1 channels.
Code:-af "pan=stereo|c0=0.5*c2+0.707*c0+0.707*c4+0.5*c3|c1=0.5*c2+0.707*c1+0.707*c5+0.5*c3"
Last edited by codemaster; 12th Dec 2023 at 23:51.
-
You can add the missing ch7 and ch8 with a factor you like, but the sum of all channels should not go to high to avoid clipping.
But you could also use it as it is and omit the missing channels. -
I made sure to prevent clipping by using the ffmpeg's "volume" filter to lower volume of input enough to prevent maximum amplitude of output to increase above -1 dB. For "-ac 2" I had to use "volume=-8.2dB" to get -1 dB max amplitude. But is there any disadvantage if I omit channels 7 and 8 when downmixing to stereo?
Last edited by codemaster; 13th Dec 2023 at 11:52.
-
-
I tested with "-ac 2" and Dave_750's formula. Source is 8 channel live concert, with -0.0 dB maximum volume. Both outputs have -1.0 dB maximum volume. Live song at 1:57:29 is 1 dB louder with the "-ac 2" formula, compared with Dave_750's formula.
But the source 8 channel audio stream is several dB louder than this when played back with PotPlayer. And the same live song on YouTube has the same low volume as I have after downmixing with both formulas.
The commands I used to downmix:
Code:ffmpeg -i infile.mkv" ^ -filter:a "volume=-8.2dB" ^ -ac 2 -codec:a pcm_f32le ^ outfile.wav
Code:ffmpeg -i infile.mkv" ^ -filter:a "volume=-4.7dB, pan=stereo|c0=0.5*c2+0.707*c0+0.707*c4+0.5*c3|c1=0.5*c2+0.707*c1+0.707*c5+0.5*c3" ^ -codec:a pcm_f32le ^ outfile.wav
Last edited by codemaster; 13th Dec 2023 at 16:39.
-
Potplayer, or your sound card, is probably downmixing to stereo without reducing the volume to prevent clipping, so it sounds louder than a stereo version where the volume was reduced while downmixing to prevent it.
For MPC-HC / Lav Filters you can enable a "normalise matrix" which means the volume is reduced according to the number of source channels so after they're combined the output can't have clipping. A normalize matrix is usually a "worst case scenario" volume reduction. The volume is reduced enough to prevent clipping even if all the channels have peaks at maximum at the same time. If they don't the downmixed stereo might be a bit quieter than it needs to be.
[Attachment 75522 - Click to enlarge]
This is the example in the ffmpeg docs for downmixing 7.1ch.
I'd probably increase the center channel volume.
I haven't tried it myself as I don't re-encode audio with ffmpeg directly a great deal, but.....
https://ffmpeg.org/ffmpeg-all.html#pan-1
If the ‘=’ in a channel specification is replaced by ‘<’, then the gains for that specification will be renormalized so that the total is 1, thus avoiding clipping noise.
pan=stereo| FL < FL + 0.5*FC + 0.6*BL + 0.6*SL | FR < FR + 0.5*FC + 0.6*BR + 0.6*SR
Foobar2000 comes with a "downmix to stereo" DSP. It has no options though and I don't know the formula it uses, but it can be added to both the playback and conversion chains.
The version of foobar2000 I've linked to below also comes with the Matrix Mixer component. You can add it to the playback chain while you fiddle around, save it as a DSP preset and then add that preset to the conversion chain. You can adjust the downmix however you like, and with the "normalize" box checked, it'll automatically reduce the over-all volume to prevent clipping. A 7.1ch to stereo downmix might look like this:
[Attachment 75524 - Click to enlarge]
foobar2000 might come with a bit of a learning curve at first, but it's worth it if you do a lot of audio encoding.
foobar2000 portable (for audio encoding)
There's also a 7.1ch->2ch preset I created that you might want to try. It combines the left surround channels without changing the volume (same with the right), then runs the resulting 5.1ch through a limiter in case combining the surround channels caused clipping, and from there it downmixes the 5.1ch to stereo using a standard formula. I borrowed the idea from tebasuna51 at doom9. MeGUI uses his Avisynth script for downmixing 7.1ch to 2ch in much the same manner.Last edited by hello_hello; 14th Dec 2023 at 09:18.
Avisynth functions Resize8 Mod - Audio Speed/Meter/Wave - FixBlend.zip - Position.zip
Avisynth/VapourSynth functions CropResize - FrostyBorders - CPreview (Cropping Preview) -
I downmixed again without adjusting volume:
Code:ffmpeg -i infile.mkv ^ -ac 2 -codec:a pcm_f32le ^ outfile.wav
Last edited by codemaster; 14th Dec 2023 at 17:01.
Similar Threads
-
Downmixing 5.1 to 2.0 using ffmpeg
By xweel in forum AudioReplies: 18Last Post: 19th Nov 2023, 07:55 -
Atmos 7.1.4 vs 11.1.4 is it significantly different?
By therock003 in forum Newbie / General discussionsReplies: 0Last Post: 10th May 2023, 03:00 -
S-VIDEO significantly grainer than A/V when digitalizing Hi8.
By BiggK in forum Camcorders (DV/HDV/AVCHD/HD)Replies: 9Last Post: 24th Dec 2021, 19:31 -
x264 Improve these settings without increasing encode time significantly
By ziggy1971 in forum Video ConversionReplies: 3Last Post: 20th Jun 2021, 01:44 -
Having troubles with eAC3to downmixing
By Dabuss55 in forum AudioReplies: 11Last Post: 7th May 2019, 14:00