HydrogenAudio

Hydrogenaudio Forum => General Audio => Topic started by: pr0m3th3u5 on 2022-11-24 08:08:19

Title: How to use Impulse Response Samples and multiple audio tracks with FFMPEG?
Post by: pr0m3th3u5 on 2022-11-24 08:08:19
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:


I use some selected IRS files on the first audio track and append the original track as follows:

Code: [Select]
    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).
Title: Re: How to use Impulse Response Samples and multiple audio tracks with FFMPEG?
Post by: ktf on 2022-11-24 14:21:45
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.
Title: Re: How to use Impulse Response Samples and multiple audio tracks with FFMPEG?
Post by: pr0m3th3u5 on 2022-11-29 14:58:02
I see, thank you.
Title: Re: How to use Impulse Response Samples and multiple audio tracks with FFMPEG?
Post by: mycroft on 2022-11-29 21:28:37
Do not ever use loudnorm in dynamics mode.
Just do not use loudnorm filter then you are 100% safe.