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.

 

Go Back   Doom9's Forum > General > Audio encoding

Reply
 
Thread Tools Search this Thread Display Modes
Old 18th July 2013, 13:42   #1  |  Link
robertcollier4
Registered User
 
Join Date: Nov 2012
Posts: 30
Dialogue nightmode downmix preset for 5.1 DTS to 2.0 AAC stereo using ffmpeg and qaac

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 and qaac.exe
Quote:
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 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.

Last edited by robertcollier4; 24th March 2014 at 00:27.
robertcollier4 is offline   Reply With Quote
Old 21st March 2014, 18:28   #2  |  Link
pm1315
Registered User
 
Join Date: Nov 2013
Posts: 1
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.
pm1315 is offline   Reply With Quote
Old 23rd March 2014, 12:42   #3  |  Link
leeperry
Kid for Today
 
Join Date: Aug 2004
Posts: 3,463
Or you can do it in your decoder in realtime and avoid double lossy reencoding.
leeperry is offline   Reply With Quote
Old 24th March 2014, 00:18   #4  |  Link
robertcollier4
Registered User
 
Join Date: Nov 2012
Posts: 30
Quote:
Originally Posted by leeperry View Post
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.

Last edited by robertcollier4; 24th March 2014 at 00:22.
robertcollier4 is offline   Reply With Quote
Old 3rd April 2014, 22:24   #5  |  Link
leeperry
Kid for Today
 
Join Date: Aug 2004
Posts: 3,463
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.
leeperry is offline   Reply With Quote
Old 13th May 2014, 07:08   #6  |  Link
Cybore
Registered User
 
Join Date: May 2014
Posts: 2
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.
Cybore is offline   Reply With Quote
Old 13th May 2014, 08:41   #7  |  Link
robertcollier4
Registered User
 
Join Date: Nov 2012
Posts: 30
@Cybore - try running this in the same directory as your MKV file.

Code:
@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:
Code:
For %%a IN ("*.mkv") Do (
to:
Code:
For %%a IN ("*.mp4") Do (

Last edited by robertcollier4; 13th May 2014 at 08:47.
robertcollier4 is offline   Reply With Quote
Old 14th May 2014, 06:46   #8  |  Link
Cybore
Registered User
 
Join Date: May 2014
Posts: 2
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.
Cybore is offline   Reply With Quote
Old 20th July 2014, 04:00   #9  |  Link
AlexKane
Registered User
 
AlexKane's Avatar
 
Join Date: Jul 2014
Posts: 20
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).
AlexKane is offline   Reply With Quote
Old 23rd July 2014, 11:56   #10  |  Link
pandy
Registered User
 
Join Date: Mar 2006
Posts: 1,044
IMHO for dialogues use of the compand effect to increase perceived loudness is better than playing with downmixing matrix.
pandy is offline   Reply With Quote
Old 19th August 2014, 18:26   #11  |  Link
rbauer
Registered User
 
Join Date: Sep 2010
Posts: 14
Quote:
Originally Posted by pandy View Post
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.
rbauer is offline   Reply With Quote
Old 7th December 2019, 08:43   #12  |  Link
orion44
None
 
orion44's Avatar
 
Join Date: Jul 2007
Location: The Background
Posts: 193
Quote:
Originally Posted by AlexKane View Post
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?
orion44 is offline   Reply With Quote
Old 7th December 2019, 12:29   #13  |  Link
tebasuna51
Moderator
 
tebasuna51's Avatar
 
Join Date: Feb 2005
Location: Spain
Posts: 5,663
You can try with the compand command of sox

You can see some samples of that command in https://forum.doom9.org/showthread.p...165#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, ...) and you need turn up the volume always with Dolby compliant sources.
__________________
BeHappy, AviSynth audio transcoder, in Doom9 forums. NicAudio, BassAudio, audio decoders.
tebasuna51 is offline   Reply With Quote
Reply

Tags
2.0, 5.1, downmix, dts, stereo

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 21:27.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2019, vBulletin Solutions Inc.