DTS to stereo downmixing

I had to perform a DTS 5.1 lossless audio track downmix to stereo in FLAC format. After a few unsuccessful trials using other software, since the lossless DTS proprietary format is tricky, I decided to resort to ffmpeg, which converted the original file yet kept all channels, leaving a file which size was bigger than the original with the command:

# ffmpeg -i original.wav -acodec flac converted.flac

Result is here.

Original size was 34.6MB, converted size was 104.9MB, so I wondered if the original was heavily compressed. So I used lac to verify the original file, and it was not, it was linear pcm in lossless format. The problem should rely on bit-depth. So to truncate those I resorted to (16-bit):

# ffmpeg -i original.wav -acodec flac -sample_fmt s16 converted16.flac

which shortened the file to 62MB. The 3F2R/LFE channel structure was still there.
So I searched for information about downmixing and I found this, so I tried the -ac2 filter as suggested:

# ffmpeg -i 'original.wav' -acodec flac -sample_fmt s16 -ac 2 -vol 425 -ar 44100 'ffmpeg_standard.flac'

I used the -ar 44100 option just to test if there was any difference, coudn't find any, so my original was already 44100, and the -vol 425 option so as to correct for decreased -6dB volume. This implements the standard conversion as described by 7.8.2 of A/52:2012 standard implementing the downmix in a way I didn't like, yet it shortened file to 24.9MB. 2 channel only were there this time.
Standard procedure is thus add -3dB center, 0dB of front and -3dB back on each channel, ommiting the LFE (sub-woofer) channel entirely. Searching for a better way of implementing the downmix without volume correction, which is deprecated and after coefficient normalizing I ended up with the ffmpeg pan filter, which allows me complete control on what I do:

# ffmpeg -i 'original.wav' -acodec flac -sample_fmt s16 -af "pan=stereo|FL=0.5*FC+0.707*FL+0.5*BL|FR=0.5*FC+0.707*FR+0.5*BR" -ar 44100 standard-3c-0f-3b.flac

which produced this file, of 23.4MB length, more or less tonally identical to the previous one. However I was not satisfied with the mix. It does not sounded me as what I could hear using VLC, which has a non-standard downmix implementation. Not enough stereo separation, excessive center voice presence, lack of extreme lows.

In all steps the tool I used to assert I didn't had excessive or too low peak levels so as to be able to normalize the coefficients was:

# bs1770gain <audio file name with extension> -ismrpt

I proceeded to implement a different approach. I suspected that at least in the case of my example I needed less center and something from the sub-woofer LFE channel. So I did:

# ffmpeg -i 'input.wav' -acodec flac -sample_fmt s16 -af "pan=stereo|FL=0.5*FC+0.707*FL+0.5*BL+0.5*LFE|FR=0.5*FC+0.707*FR+0.5*BR+0.5*LFE" -ar 44100 'try-6c-3f-3b-6sw.flac'

resulting in this file. Still too much center and this time excessive low-end.

So I tried:

# ffmpeg -i 'input.wav' -acodec flac -sample_fmt s16 -af "pan=stereo|FL=0.25*FC+0.707*FL+0.35*BL+0.25*LFE|FR=0.25*FC+0.707*FR+0.35*BR+0.25*LFE" -ar 44100 'try-12c-3f-9b-12sw.flac'

resulting in this file. Lack of center and what seemed correct low-end.

The final pick was:

# ffmpeg -i 'input.wav' -acodec flac -sample_fmt s16 -af "pan=stereo|FL=0.35*FC+0.707*FL+0.5*BL+0.25*LFE|FR=0.35*FC+0.707*FR+0.5*BR+0.25*LFE" -ar 44100 'selected-9c-3f-6b-12sw.flac'

resulting in this final choosen file.

I hope this is useful for those who want to try their own approach.

Appendix:

in all coefficient calculations it is assumed that:
at=gain in dB (if negative it is attenuation)
coef=coefficient value
at=20*log10(coef)
coef=10^(at/20)

All information is provided as is, without any warranties.
If you liked this page, you may express it below...it won't cost you a dime...