[mythtv-users] Commercial detection with silence - silence.cpp
HP-mini
blm-ubunet at slingshot.co.nz
Sat Aug 10 20:49:34 UTC 2013
On Sat, 2013-08-10 at 09:28 +0000, mythtv at phipps-hutton.freeserve.co.uk
wrote:
>
> > On 10 August 2013 02:55, Roger Siddons <dizygotheca at ntlworld.com> wrote:
> >
<snipped>
Could use another form of average that allows samples to be
added/removed without access to dataset & without knowing the final set
size. (like calculator)
// Allocate data buffer to contain audio from one video frame.
const size_t frameSamples = metadata.channels * metadata.samplerate /
25.0;
// determine average audio level in this frame
long avgabs = 0;
for (unsigned i = 0; i < frameSamples; i++)
avgabs = (avgabs / (i+1)) * i + abs(samples[i]) / (i+1);
Now that avgabs can not overflow you could possibly scale it up to
reduce error from integer division.
More information about the mythtv-users
mailing list