I watch movies on TV with headphones. The movie files usually have Dolby or DTS with surround sound. But sometimes I see subtitles and hear no sound so I am guessing the TV does some bad downmixing.
So I took it upon myself to downmix them and I decided so thrown in some surround virtualization for some good measure. I used the IRS files from the excellent HeSuVi project (https://sourceforge.net/projects/hesuvi/files/). There posts helped me with it:
- GUIDE: Using ffmpeg for virtual surround (a way better solution than Dolby Headphone & foobar2000!) (https://teddit.net/r/headphones/comments/fo4bkf/guide_using_ffmpeg_for_virtual_surround_a_way/)
- PSA: You can get HeSuVi on your VFIO with PulseAudio (https://teddit.net/r/VFIO/comments/k3u36r/psa_you_can_get_hesuvi_on_your_vfio_with/)
I use some selected IRS files on the first audio track and append the original track as follows:
ffmpeg \
-i "media/IN.mkv" \
-i "irs/dh++.wav" \
-i "irs/atmos.wav" \
-i "irs/dtshx.wav" \
-i "irs/gsx.wav" \
-c:v copy \
-c:s copy \
-c:a libmp3lame -q:a 0 \
-filter_complex "[1:0]pan=16c|c0=c0|c1=c1|c2=c8|c3=c7|c4=c6|c5=c13|c6=c6|c7=c13|c8=c4|c9=c5|c10=c12|c11=c11[hrirs0];[0:a][hrirs0]headphone=map=FL|FR|FC|LFE|BL|BR:hrir=multich[hf0];[hf0]loudnorm[nor0]" \
-filter_complex "[2:0]pan=16c|c0=c0|c1=c1|c2=c8|c3=c7|c4=c6|c5=c13|c6=c6|c7=c13|c8=c4|c9=c5|c10=c12|c11=c11[hrirs1];[0:a][hrirs1]headphone=map=FL|FR|FC|LFE|BL|BR:hrir=multich[hf1];[hf1]loudnorm[nor1]" \
-filter_complex "[3:0]pan=16c|c0=c0|c1=c1|c2=c8|c3=c7|c4=c6|c5=c13|c6=c6|c7=c13|c8=c4|c9=c5|c10=c12|c11=c11[hrirs2];[0:a][hrirs2]headphone=map=FL|FR|FC|LFE|BL|BR:hrir=multich[hf2];[hf2]loudnorm[nor2]" \
-filter_complex "[4:0]pan=16c|c0=c0|c1=c1|c2=c8|c3=c7|c4=c6|c5=c13|c6=c6|c7=c13|c8=c4|c9=c5|c10=c12|c11=c11[hrirs3];[0:a][hrirs3]headphone=map=FL|FR|FC|LFE|BL|BR:hrir=multich[hf3];[hf3]loudnorm[nor3]" \
-map 0:v:0 \
-map [nor0]:a -metadata:s:a:0 title="Dolby Headphone DH-2 Cinema" \
-map [nor1]:a -metadata:s:a:1 title="Dolby Atmos 7.1 Headphones" \
-map [nor2]:a -metadata:s:a:2 title="DTS Headphone:X" \
-map [nor3]:a -metadata:s:a:3 title="Sennheiser GSX 7.1 Binaural" \
-map 0:a:0 \
-map 0:s:0 \
"media/OUT.mkv"
If you can't read the code here, check it out on pastebin (https://pastebin.com/hv02V0RP).
- Am I doing it right?
- My intention is to preserve the first original audio track but even it is getting encoded... how do I just copy the first audio track?
- I think I am using `loudnorm` more than once... should I just use it on the IRS files themselves?
- Or is there a better way?
- Do I need to use multiple "filter complexes"? My attempt to use just one failed. (https://pastebin.com/KPE6endd)
My intention is to preserve the first original audio track but even it is getting encoded... how do I just copy the first audio track?
I think you'll need to replace -c:a libmp3lame with -c:a:0 copy -c:a:1 libmp3lame -c:a:2 libmp3lame etc. or something like that. I haven't tested, so I'm not sure.
Do not ever use loudnorm in dynamics mode.
Just do not use loudnorm filter then you are 100% safe.