Compare different language audio tracks

Where all the user feedback and suggestions for improvements go
Post Reply
Zuikkis
Posts: 8
Joined: Mon Nov 27, 2017 10:12 pm

Compare different language audio tracks

Post 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? :)
Zuikkis
Posts: 8
Joined: Mon Nov 27, 2017 10:12 pm

Re: Compare different language audio tracks

Post 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.
erik
Site Admin
Posts: 3368
Joined: Sun Aug 21, 2005 3:49 pm

Re: Compare different language audio tracks

Post 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
Post Reply