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. |
26th October 2018, 00:48 | #1 | Link |
Registered User
Join Date: Feb 2018
Posts: 1
|
Downmixing 5.1 to 2.0 - FFmpeg vs VLC
Hi,
I'm writing here to get some opinions on how you feel about the differences FFmpeg and VLC are handling surround to stereo downmixing. If you don't know of the problem, here it is (I assume you have stereo speakers, and I hope I'm not the only person seeing/hearing this): Open any surround sound AC-3 file in VLC. Let FFmpeg downmix the same file to stereo and open it up in another VLC instance. Skip to a file position with dialogues and at first let the original file play for some seconds, then the one converted by FFmpeg. The latter one should be more quiet (at least it is for me). Now let's have a look at the basics. I think the "most official" way to downmix is given in the AC-3 standard specification. It more or less says (page 95): Mix the center channel to both front channels with -3dB and mix the rear channels to the according front channel, again with -3dB. After that, coefficients are applied to re-normalize the mix. With the basics clear, FFmpeg does exactly that. I looked it up in the sources (you will need ac3.h, ac3_parser.c and ac3dec.c in the libavcodec directory). The results sound the same if you use Code:
-ac 2 or -af "pan=stereo|FL < 1.0*FL + 0.707*FC + 0.707*BL|FR < 1.0*FR + 0.707*FC + 0.707*BR" My opinion when comparing these two outputs is that the downmix VLC does is more clearly understandable than the one FFmpeg does. Do you get my point? What's your opinion? Last edited by Exxess; 26th October 2018 at 00:48. Reason: typo |
26th October 2018, 02:50 | #2 | Link |
Broadcast Encoder
Join Date: Nov 2013
Location: Royal Borough of Kensington & Chelsea, UK
Posts: 2,883
|
I see...
Yes, they might be different, but I never trusted VLC anyway. In this specific case, it seems that VLC has effects and other sounds slightly higher than it should be compared to the speech. FFmpeg should also be able to apply a down mix using better and more known matrices like the Dolby Pro Logic II that would make the resulting stereo stream sound way better than the VLC down mix. Unless you are particularly interested in using VLC for whatever reason, I suggest you to install the k-lite codec pack along with MPC-HC. The pack will install the LAV Filters that you'll be using to handle audio and video. MPC-HC is very detailed with different renders and different options. As to the LAV Filters, you'll be able to set your preferred down mix method and the way audio is handled. Another good player that does a down mix on the fly with many tweakable options is Potplayer, which uses the OpenCodecs instead. I personally use these two on Windows and MPV on Linux. Cheers. P.s if you are asking why they implemented it that way on VLC instead, I don't know, but if you are willing to, you may commit a change to the source to add a better down mix. Last edited by FranceBB; 26th October 2018 at 02:53. |
26th October 2018, 05:25 | #3 | Link | |||
Registered User
Join Date: Sep 2003
Location: Berlin, Germany
Posts: 3,078
|
Quote:
Quote:
By FranceBB: Quote:
Cheers manolito Last edited by manolito; 26th October 2018 at 05:28. |
|||
26th October 2018, 11:19 | #4 | Link |
Registered Developer
Join Date: Mar 2010
Location: Hamburg/Germany
Posts: 10,340
|
I agree with manolito, those Dolby Pro Logic downmixes are not designed for the best experience listening on Stereo speakers or headphones, they are designed to be able to recover some surround effects from a stereo signal with a Dolb Pro Logic decoder at the other end.
__________________
LAV Filters - open source ffmpeg based media splitter and decoders |
26th October 2018, 12:37 | #5 | Link |
Moderator
Join Date: Feb 2005
Location: Spain
Posts: 6,890
|
- There are two way to normalize peaks, and it is needed to avoid clip audio:
1) Make two passes, like AviSynth can do. Like Manolito script and a Normalize() after. In first pass we know the big peak obtained and in second pass attenuate or gain until the big value without clip (1.0 or any other value requested <1.0). Without two passes we can do the best normalization, then VLC or ffmpeg can't do this mode and need use the second method. 2) Use normalized coeficients to guarantee than never go over 1.0. For instance the ffmpeg downmix: -af "pan=stereo|FL = 1.0*FL + 0.707*FC + 0.707*SL|FR = 1.0*FR + 0.707*FC + 0.707*SR" (WARNING: surround channels must be SL,SR, not BL,BR) can produce peak values until 2.414 than are cliped to 1.0 making distortion. The normalized version of this mix is: -af "pan=stereo|FL = 0.414*FL + 0.293*FC + 0.293*SL|FR = 0.414*FR + 0.293*FC + 0.293*SR" When use '<' instead '=' ffmpeg change the coeficients to normalized version. Also there are many ways to define the coeficients and the contribution to the final mix. In a AC3 5.1 stream there are header fields like: cmixlev: Center Mix Level, 2 Bits, values: 0.707 (–3.0 dB), 0.595 (–4.5 dB), 0.500 (–6.0 dB) surmixlev: Surround Mix Level, 2 Bits, values: 0.707 (–3 dB), 0.500 (–6 dB), 0 than a compliant decoder must obey in order to obtain the downmix. Of course a ffmpeg -af "pan=stereo..." override these values. There are also dpl and dpl II downmix, for instance: -af "pan=stereo|FL = 0.3254*FL + 0.2301*FC + 0.2818*SL + 0.1627*BR|FR = 0.3254*FR + 0.2301*FC - 0.1627*BL - 0.2818*SR" That mix is only recommended to be used by AV with dplII decoder, to be played like stereo is worse than simple stereo (the coeficient of FC is worse). Also, if want include LFE (not recommended by Dolby) the FC normalized coeficient must be worse. But using normalized coeficients we can obtain less volume, maybe VLC don't use normalized coeficients with risk of clip. I'm not sure but in VLC -> Preferences -> Audio -> Normalize volume to -> 2.0 (by default) Maybe if you put here 1.0 the behaviour is the same than with ffmpeg.
__________________
BeHappy, AviSynth audio transcoder. |
Tags |
downmix, stereo |
Thread Tools | Search this Thread |
Display Modes | |
|
|