Skip to main content

Notice

Please note that most of the software linked on this forum is likely to be safe to use. If you are unsure, feel free to ask in the relevant topics, or send a private message to an administrator or moderator. To help curb the problems of false positives, or in the event that you do find actual malware, you can contribute through the article linked here.
Topic: How to use Impulse Response Samples and multiple audio tracks with FFMPEG? (Read 576 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

How to use Impulse Response Samples and multiple audio tracks with FFMPEG?

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. 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.
  • 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.

Re: How to use Impulse Response Samples and multiple audio tracks with FFMPEG?

Reply #1
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.
Music: sounds arranged such that they construct feelings.

Re: How to use Impulse Response Samples and multiple audio tracks with FFMPEG?

Reply #2
I see, thank you.

Re: How to use Impulse Response Samples and multiple audio tracks with FFMPEG?

Reply #3
Do not ever use loudnorm in dynamics mode.
Just do not use loudnorm filter then you are 100% safe.