[mythtv] Commercial Detector questions

Chris Pinkham cpinkham at bc2va.org
Fri Dec 9 14:45:09 EST 2005

> Chris Pinkham and interested persons,
> I've been messing with the commercial detector in 18.1 (very similar to svn 
> version) to improve detection of Australian ads.  Here is what I've found so 
> far using the ALL method:

Yeah, I haven't spent much time recently in the flagger although there are a
few things on my TODO that I'm thinking of looking into after 0.19 is out.

>  - Strict is better because otherwise all white screens detected as blanks.

I agree and I run with AggressiveCommDetect ON on my system.  I think there
are some countries that don't use black blank screens, but instead use some
other color and that is the reason for the non-strict definition of blank.

>  - Australia doesn't have blanks between ads so changed MAX_COMM_LENGTH to 
> match MAX_COMM_BREAK_LENGTH (is this the right thing to do?)

I think that would accomplish what you want yes.  In SVN, you could use
the undocumented 'CommDetectMaxCommLength' setting in the DB.

>  - Patch to 18.1 to zero formatCount and use format instead of aspect


>  - Patches to match my global record before of 5 minutes and after 10 minutes
> 	- Pick format from 5 minutes to last 10 minutes
> 	- Move Logo detecting 6 minutes in and if not detected try in 15 minutes in
> 	(it maybe more sensible to reduce my before time to 1 minutes)

With current SVN, we now have the ability to know the program's scheduled
start and end times in addition to the actual recording's start and end times.
I think that post-0.19, we could make mythcommflag look inside the scheduled
timeperiod for the format and logo and not at the actual recording start since
we may have started recording early.  I made a note on my TODO to look into
this unless you want to take a look at it.

The 6 vs 15 minute thing would have to be able to handle in-progress
recordings also, so it wouldn't try them unless we were far enough behind.
For in-progress recordings, we could delay until requiredHeadStart seconds
past the actual program's scheduled start time to handle the logo detection.

> Does commercial detection hang if never 8 minutes of video for logo detection?

This is possible, I've never tested a recording that short, but I did put in
a check the other day to not to realtime flagging if the recording is shorter
than requiredHeadStart (which is about 7.5 minutes if logo detection is On
and 30 seconds if logo detection is Off (now 60 in SVN HEAD)).

> Does it make sense to +10 score when format matches?  My understanding is 
> format matches mean either show or ad.  And format non matches mean ad.

For this, are you thinking take out the +10 when formatMatch >
(fbp->frames * .90) and leave in the -10 when formatMatch <
(fbp->frames * .10)?

Your logic makes sense, we are more sure that something is not part of the
show if it's format does not match the show so we can -10 there, but
we aren't as sure what it is if the format does match so why +10 in that
case.  I made a note about this also.

> Having no experience with Fuzzy Logic I'm very impressed.

I'm amazed it works so well sometimes.  The original commercial detection
code in Myth used only blank frames and that worked fairly well at the
time, but as time went by it got worse and worse.  I prefer more concrete
things that either work or don't, so the commercial detection is my first
adventure down something as fuzzy as this. :)

Just to give you an idea of what other things I may be looking into
shortly, here are a few things from my TODO:

* Keep track of min/max brightness found during logo detection so we can
  use that information later to determine what is really a blank screen and
  what is not.  (ie, if the min is only 50, we might want to try to
  compensate in some of our other thresholds)

* Fade detection, checking the last X number of frames to see if the
  brightness is constantly increasing or decreasing.

* Better logo detection.  I looked into this for a while but haven't messed
  with that code at all recently.  Detecting the logo is easy using something
  like sobeil, checking for the logo in each frame after you've found what
  the logo looks like that is the part that is a bit harder since we're
  dealing with video.


More information about the mythtv-dev mailing list