<!DOCTYPE html><html><head><meta http-equiv="Content-Type" content="text/html; charset=us-ascii"><meta name="Generator" content="Microsoft Word 14 (filtered medium)"><style><!--
/* Font Definitions */
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0cm;
        margin-bottom:.0001pt;
        font-size:11.0pt;
        font-family:"Calibri","sans-serif";
        mso-fareast-language:EN-US;}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:purple;
        text-decoration:underline;}
span.EmailStyle17
        {mso-style-type:personal-compose;
        font-family:"Calibri","sans-serif";
        color:windowtext;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-size:10.0pt;}
@page WordSection1
        {size:612.0pt 792.0pt;
        margin:72.0pt 72.0pt 72.0pt 72.0pt;}
div.WordSection1
        {page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
<style type="text/css">body { font-family:'DejaVu Sans'; font-size:13px}</style>
</head>
<body lang="EN-AU" link="blue" vlink="purple">On Fri, 09 Aug 2013 01:33:01 +0100, Mark Perkins &lt;perkins1724@hotmail.com&gt; wrote:<br><br><blockquote style="margin: 0 0 0.80ex; border-left: #0000FF 2px solid; padding-left: 1ex"><div class="WordSection1"><p class="MsoNormal"><span lang="EN-GB">With reference to the Commercial detection with silence for UK freeviewHD wiki page at <a href="http://www.mythtv.org/wiki/Commercial_detection_with_silence_for_UK_freeviewHD">http://www.mythtv.org/wiki/Commercial_detection_with_silence_for_UK_freeviewHD</a></span></p><p class="MsoNormal"><span lang="EN-GB"><o:p>&nbsp;</o:p></span></p><p class="MsoNormal"><span lang="EN-GB">I’m new to MythTV so sorry if this is a dumb question or has been covered elsewhere.</span></p><p class="MsoNormal"><span lang="EN-GB"><o:p>&nbsp;</o:p></span></p><p class="MsoNormal"><span lang="EN-GB">I managed to get the scripts to compile and install with no problems however was not able to get the silence detection to work correctly. It either detected no silences, or every frame as silent depending on the threshold db set with only a very small decimal change required to move from no silences to all silences. There was nothing in between, it was all or nothing.</span></p><p class="MsoNormal"><span lang="EN-GB"><o:p>&nbsp;</o:p></span></p><p class="MsoNormal"><span lang="EN-GB">Long story short, after much troubleshooting I found that I was having problems with the comparison between the set threshold and the avgabs variable declared in the silence.cpp code.</span></p><p class="MsoNormal"><span lang="EN-GB"><o:p>&nbsp;</o:p></span></p><p class="MsoNormal"><span lang="EN-GB">I found that if I replaced line 373 of silence.cpp:</span></p><p class="MsoNormal"><span lang="EN-GB"><o:p>&nbsp;</o:p></span></p><p class="MsoNormal"><i><span lang="EN-GB">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // determine average audio level in this frame</span></i></p><p class="MsoNormal"><i><span lang="EN-GB">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; long avgabs = 0;</span></i></p><p class="MsoNormal"><span lang="EN-GB"><o:p>&nbsp;</o:p></span></p><p class="MsoNormal"><span lang="EN-GB">with:</span></p><p class="MsoNormal"><span lang="EN-GB"><o:p>&nbsp;</o:p></span></p><p class="MsoNormal"><i><span lang="EN-GB">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // determine average audio level in this frame</span></i></p><p class="MsoNormal"><i><span lang="EN-GB">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; float avgabs = 0;</span></i></p><p class="MsoNormal"><span lang="EN-GB"><o:p>&nbsp;</o:p></span></p><p class="MsoNormal"><span lang="EN-GB">that the threshold comparison would work correctly and silences were detected correctly. In fact it works very well for me now.</span></p><p class="MsoNormal"><span lang="EN-GB"><o:p>&nbsp;</o:p></span></p><p class="MsoNormal"><span lang="EN-GB">But I am confused as to why this was causing a problem for me and not for others? Have I missed something else?</span></p><p class="MsoNormal"><span lang="EN-GB"><o:p>&nbsp;</o:p></span></p><p class="MsoNormal"><span lang="EN-GB">Any assistance or comments appreciated.</span></p><p class="MsoNormal"><span lang="EN-GB"><o:p>&nbsp;</o:p></span></p></div></blockquote><div><br></div><div>Hi Mark,<br></div><div><br></div><div>Welcome to Myth. </div><div><br></div><div>It's the first I've heard of it so thanks for taking the trouble to debug it &amp; post. IMHO you've identified a real problem.<br></div><div><br></div><div>I'm away from home at the moment so can't investigate, but I'm guessing that frameSamples is so large that the calculation is underflowing the long.</div><div><br></div><div>It would be interesting to know your platform/compiler &amp; the audio channels/samplerate of your programmes (mythffmpeg -i &lt;sample&gt;).</div><div><br></div><div>I run an older version with 2 channels @ 8k but I know Tim/Hippo has been optimizing the wiki version lately, so his experience will be the most pertinent. It would also be interesting to see if changing kUpmix_Channels to 2 makes any difference.</div><div><br></div><div>Although using float is safest, I'm sure there must be a better solution. If any audio/C gurus are reading, then here's the code in question. What's the appropriate portable C++ type to use that will cope with all audio formats ?</div><div><br></div><div>           <em>// Allocate data buffer to contain audio data from one video frame.</em><em><br></em><em>const size_t frameSamples = metadata.channels * metadata.samplerate / 25.0;</em></div><div><em><br></em></div><div><em>// determine average audio level in this frame</em><em><br></em><em>        long avgabs = 0;</em><em><br></em><em>        for (unsigned i = 0; i &lt; frameSamples; i++)</em><em><br></em><em>&nbsp;           &nbsp; &nbsp;avgabs += abs(samples[i]);</em><em><br></em><em>        avgabs = avgabs / frameSamples;</em></div><em><br></em></body></html>