0
votes

I wanted to compare how much two sound frames are similar, so that I can distinguish between them.

I am doing this because, usually when we had a video playing and an advertisement comes up, usually there is either a sound drop or an increase in sound.

So I want to compare the sound frames from wav file to find the difference.

The following code finds the amplitude of sound wave per video frame

1 video frame corresponds to 2000 sound frames.

Code ---->

for (offset=waveFileHeaderOffset; ((offset < raf.length()) && (videoFrames < VideoFile.MAX_POSSIBLE_FRAMES)); offset+=2*AUDIO_PER_FRAME) 
{
          audioAmplitude = 0.0;    
          for (offset2=0; offset2 < 2*AUDIO_PER_FRAME; offset2+=2 )
           {
                double temp = 0.0;
                raf.seek(offset+offset2);
                raf.read(bytes);
                temp = (double) Math.abs((double)( ( ( bytes[1]  << 8 ) | ( bytes[0] & 0xff ) ) / 32768.0 ));
                audioAmplitude += temp;

            }
            audioAmplitude /= AUDIO_PER_FRAME;//we are taking average of all frames corresponding to video frame

            ArrayList<Double> tempFrameData = new ArrayList<Double>();
            (VideoFile.frameHashMap.get(videoFrames).clone());
            tempFrameData.add(audioAmplitude);


            VideoFile.frameHashMap.put(videoFrames, tempFrameData);

            videoFrames++;

     }

The problem is that since the amplitude is divide by 32768 to normalize it. I cant determine a threshold to distinguish between them.

All amplitude are very close to each other. I think I am making some mistake in calculating the amplitude.

Can any one comment on how do I compare two frames using these amplitudes to find significant difference when a advertisement comes up in between a video.

Thanks

1
whats a significant difference to you?0x6C38
Like when an advertisement comes in between videos, usually the amplitude of sound in advertisements is far more than that of videos. Secondly, suppose there is a video with a guy interviewing another guy. Here the overall loudness of sound is same for the interview unless some other advertisement abruptly comes in between. I want to measure this change. But when I find amplitude using above code. All the values are very close. Cant find a threshold to distinguish. Cant find the error as welluser2290024
I thought taking difference between amplitudes of two sound frames would do. But that is not working. It does not help distinguishing themuser2290024
Will finding difference using RMS(Root Mean square) work ?user2290024
we can only speculate, I doubt any of us has ever tried to do this before, the only way t go is testing0x6C38

1 Answers

0
votes

http://en.wikipedia.org/wiki/Loudness_war
The article is mostly about music but it applies to commercials too. The most interesting part is about the dynamic range reduction.

Studies have found that the human hear prefer "loud" signals instead of "weak" signals.
When you're trying to sell something, that comes in handy.