View Full Version : Dialogue nightmode downmix preset for 5.1 DTS to 2.0 AAC stereo using ffmpeg and qaac
robertcollier4
18th July 2013, 12:42
After converting many DTS movie tracks from 5.1 to 2.0 using eac3to, I have found the default eac3to channel mappings to result in very quiet dialogues and overly loud music and action scenes. Although the eac3to channel downmix coefficients have a scientific basis, they often do not sound good in practice bceause of low dialogue volume. This preset is for those looking for clear dialogues with left and right channel music still being audible but more in the background.
Requires: ffmpeg.exe (http://ffmpeg.zeranoe.com/builds/) and qaac.exe (https://sites.google.com/site/qaacpage/)
ffmpeg.exe -report -loglevel verbose -i "videofile.mkv" -map 0:a:0 -f wav -acodec pcm_f32le -ac 2 -af pan=stereo:FL=FC+0.30*FL+0.30*BL:FR=FC+0.30*FR+0.30*BR - | qaac.exe --tvbr 127 --quality 2 --rate keep --ignorelength --no-delay - -o "audio-2ch-downmix.m4a"
The default eac3to channel matrix (http://forum.doom9.org/showthread.php?p=1600695#post1600695) is:
FL' = 0.71*FC + FL + BL
FR' = 0.71*FC + FR + BR
This "nightmode" preset uses the following channel matrix:
FL' = FC + 0.30*FL + 0.30*BL
FR' = FC + 0.30*FR + 0.30*BR
As you can see - front center (dialogues) come in properly now and stay at the original level - while the music and explosions remain a background effect and don't overpower you. This preset solves the problem of you having to constantly fiddle with the volume knob when watching DTS 5.1 converted to 2.0 movies in order to hear dialogues. (Especially for watching movies in the night where you don't want to wake others but still want to be able to hear dialogues).
Try it out and you will notice a much better movie watching experience for 5.1 to 2.0 converted movies.
pm1315
21st March 2014, 18:28
Robert,
Thanks for this. I wanted to clarify something on your command
line. Is the -ac2 switch prior to the -af switch necessary? It seemed to work ok if I left it out. Thanks.
leeperry
23rd March 2014, 12:42
Or you can do it in your decoder in realtime and avoid double lossy reencoding.
robertcollier4
24th March 2014, 00:18
Or you can do it in your decoder in realtime and avoid double lossy reencoding.
@leeperry -
There is no double-lossy encoding here, that was made sure of. Ffmpeg is muxing 5 channels to 2 channels - and then passing that to qaac as a 32-bit float PCM (raw) data stream. It was also verified that the actual libdts module returns 32-bit float PCM - so there is no dithering happening when the data is being passed from ffmpeg libdts decoder to qaac aac encoder. The lossy encoding is happening only once - and that is by QuickTime AAC (qaac command line).
This is why we are explicitly telling ffmpeg to "-acodec pcm_f32le".
Yes you could do the AAC encoding with ffmpeg - but I hydrogenaudio listening tests show that the best encoder is Quicktime AAC encoder.
leeperry
3rd April 2014, 21:24
DTS & AAC are both lossy, so that's double-lossy...or maybe you meant DTS HD MA...still, you can use ffdshow audio's(and even LAV Audio's I think) built-in decoding matrix and downmix to stereo using custom coeffs in realtime without any encoding whatsoever. I do it all the time, with VST plugins on top of it and it's all processed in 32fp and fed to Reclock as is.
Cybore
13th May 2014, 06:08
Sorry for bumping an old thread but I wanted to see if someone could perhaps fill a request.
I found this post really useful. I use a 2.0 system and like to watch movies at night, so the volume fluctuations can really be very annoying. Re-encoding the audio via this is really quick and can make a big difference in watching movies with a lot of actions and explosions.
I was wondering, if its not to difficult, possible for someone to write a batch that does just this to a file that is dragged into the batch. It would save a lot of time and convenience. It would also be nice if it merged the converted audio file into a new mkv but it would not be absolutely necessary.
I tried doing it myself but was not capable of doing so. Just thought I'd give it a shot.
robertcollier4
13th May 2014, 07:41
@Cybore - try running this in the same directory as your MKV file.
@echo off
set PATH_MKVMERGE=E:\PortableApps\VideoProcessing\mkvtoolnix
set PATH_QAAC=E:\PortableApps\VideoProcessing\qaac
set PATH_FFMPEG=E:\PortableApps\VideoProcessing\ffmpeg
set PATH=%PATH%;%PATH_MKVMERGE%;%PATH_QAAC%;%PATH_FFMPEG%
@echo on
cd /d %~dp0
For %%a IN ("*.mkv") Do (
echo ---------------------- BATCH STARTING %%~na%%~xa
ffmpeg.exe -report -loglevel verbose -i "%%~na%%~xa" -map 0:a:0 -f wav -acodec pcm_f32le -ac 2 -af pan=stereo:FL=0.25*FL+FC+0.6*LFE:FR=0.25*FR+FC+0.6*LFE - | qaac.exe --tvbr 127 --quality 2 --rate keep --ignorelength --no-delay - -o "%%~na-ffmpeg.m4a" 1>>qaac.log 2>&1
If exist "%%~na.srt" (
mkvmerge.exe --split 4000M -o "%%~na-2chnightmode%%~xa" --no-chapters --no-audio "%%~na%%~xa" "%%~na-ffmpeg.m4a" "%%~na.srt" 1>>"mkvmerge.log" 2>&1
) Else (
mkvmerge.exe --split 4000M -o "%%~na-2chnightmode%%~xa" --no-chapters --no-audio "%%~na%%~xa" "%%~na-ffmpeg.m4a" 1>>"mkvmerge.log" 2>&1
)
)
This will convert all MKV files in the current directory. If you would like it to similarly convert other filetypes, such as .MP4 - just replace the line:
For %%a IN ("*.mkv") Do (
to:
For %%a IN ("*.mp4") Do (
Cybore
14th May 2014, 05:46
Thank you so much, just gave it a try and it worked. I did notice that it split my file, but that was because of the split string you included. Just increasing the numbers did the trick.
AlexKane
20th July 2014, 03:00
While custom matrixing coefficients will alleviate the dynamic range inconsistencies, it may still not be a "proper" solution.
Replicating Dolby's DRC system in a DAW with FilmLight/Standard compression presets is a better option.
The problem with custom matrices is that they alter the stereo imaging, resulting in a very pronounced center (if you boost the center channel for dialogue intelligibility).
pandy
23rd July 2014, 10:56
IMHO for dialogues use of the compand effect to increase perceived loudness is better than playing with downmixing matrix.
rbauer
19th August 2014, 17:26
IMHO for dialogues use of the compand effect to increase perceived loudness is better than playing with downmixing matrix.
Imho the robertcollier4's solution is simpler, quicker and works fine too.
orion44
7th December 2019, 08:43
While custom matrixing coefficients will alleviate the dynamic range inconsistencies, it may still not be a "proper" solution.
Replicating Dolby's DRC system in a DAW with FilmLight/Standard compression presets is a better option.
Can this be done in Audacity?
Here is, for example, Dolby's "Film Standard" DRC preset:
Max Boost: 6 dB (below -43dB).
Boost Range: -43 to -31dB (2:1 ratio).
Null Band Width: 5dB (-31 to -26dB).
Early Cut Range: -26 to -16dB (2:1 ratio).
Cut Range: -16 to +4dB (20:1 ratio).
How do we replicate, if possible, these options in Audacity or other audio editors?
tebasuna51
7th December 2019, 12:29
You can try with the compand command of sox (http://sox.sourceforge.net/)
You can see some samples of that command in https://forum.doom9.org/showthread.php?p=779165#post779165
Don't work fine with avisynth soxfilter but you can try with sox command line.
Remember than Dolby Compression curves are based in normalized dialog (at -31 dB, for that the Null Band preserved), but not all sources are compliant with that and the output can't be like desired.
The Dolby recomendations (Dialog Normalization, DRC system) are good if all sources respect them, but there are many sources with high volume (TV commercials, Loudness war (https://en.wikipedia.org/wiki/Loudness_war), ...) and you need turn up the volume always with Dolby compliant sources.
vBulletin® v3.8.11, Copyright ©2000-2026, vBulletin Solutions Inc.