Page 1 of 1

Compare different language audio tracks

Posted: Mon Dec 18, 2017 8:59 pm
by Zuikkis
I have a few channels that are hard for Comskip. Channel logo is always on, and audio is only two channels always.

However I noticed that while there are two different audio tracks (original and dubbed), commercials are always on single language. So both audio tracks are playing the same data during commercial!

I made a quick and dirty test, extract both tracks with ffmpeg:

ffmpeg -i 00001.ts -map 0:1 lang1.wav -map 0:2 lang2.wav

Then I made my own C program that simply reads these files and compares in 1152 sample blocks (mp2 block size).. They are not exact matches, but very close, and always exact 1152 sample boundaries so they are quick to match. This finds the commercials really well.

But the problem is that if there is any errors in the original file, the generated .wavs can be much shorter than the full video, and then the cutpoints are wrong. So I can't really use my own program, it's not reliable because of this.. So I'm asking, is it possible to add to Comskip? :)

Re: Compare different language audio tracks

Posted: Wed Dec 20, 2017 4:32 pm
by Zuikkis
I actually fixed my own program. :) The secret is to add some parameters to ffmpeg:

ffmpeg -y -i 00001.ts -map 0:1 -af "aresample=async=1" lang1.wav -map 0:2 -af "aresample=async=1" lang2.wav

"aresample=async=1" filter fixes the timeline by adding silence when needed, so the generated wav has correct timing.

But still this might be usable in Comskip. I can provide you with an example clip if needed.

Re: Compare different language audio tracks

Posted: Thu Dec 21, 2017 11:00 am
by erik
Going to my test files its clear you have found a rather unique way to detect the commercials under your specific conditions
Not sure it will be useful for many people