igorpavlov
igorpavlov

Reputation: 3626

Compare two audio files and find cut

|_____|_____|_____|_____|_____|_____| WAV

|_____|_____|_____|_____| MP3 (out of the WAV above)

|_____|_____|..........|_____|..........|_____| diffs

            \    \      \    \  <-- need timestamps of cut areas

I have a lot of WAV files and my editors are creating MP3 files out of them. They are being normalised and equalised, plus some areas are being cut.

I need to automatically find those areas which they have cut and get timestamps of cuts with a highest possible precision.

I have spent a solid amount of time in Google trying to find a solution, but without any luck. No answers on SO on questions such as:

Also found https://code.google.com/archive/p/musicip-libofa/, but their producer's site is down and there is no documentation on the project.

Please help! 🎧

Upvotes: 0

Views: 924

Answers (1)

PatriceG
PatriceG

Reputation: 4063

I suppose you can compare the temporal values of the two signals, until you find a big difference (first timestamp). Then, you compare them again until you find that there is no difference anymore (second timestamp).

As .wav and .mp3 files are not in the same format, you can't do it from the temporal samples values. In the spectral domain, you could compare each frame one by one (the numbers should not be exactly the same, but you could use a threshold to see if the difference is small enough.

In your example, the two files strat from the same point. You can compare successive spectrums of the two files until you find a big difference. That gives you the first timestamp of cut. Then you go on until the difference become small again, and so on.

If you don't want to go in the spectral domain, a simpler approach could be to use a feature, like the rms energy of the signal, or the spectral centroid.

In all cases, you need first to read the audio files, then to process the values, in order to obtain an other representation of the data that can be compared.

Upvotes: 2

Related Questions