[mythtv] Re: [mythtv-commits] mythtv commits

Risto Treksler risto at elkhornbanff.ca
Thu Apr 21 08:43:46 UTC 2005

On Wednesday 20 April 2005 08:39 pm, Chris Pinkham wrote:
> Better grab a cup of coffee if you plan on reading this. :)

yeah, that's what i should have said :)

actually, nevermind a cup
better bring the whole pot over

> They are both wrong
> in saying that the next block appears to be a commercial block
> because there is nothing that indicates that, we haven't even looked at
> the score for the block.  The only thing we're basing the fact that
> the next block is part of a commercial break or not is the length.


> Something more correct is probably:
>         QString("Ignoring blocks starting at frame %1 "
>                 "with length %2, length is under minimum "
>                 "comm block length of %3 seconds.")
>                 .arg(curBlock)
>                 .arg(fbp->start - breakStart)
>                 .arg(commDetectMinCommBreakLength));

this looks fine
it makes a lot of sense when viewing the debug output

> >>   - Revert the change (temporarily for now) that made strict mode
> >> require blank frames to be totally blank so frames with logos on them
> >> but otherwise blank would not be detected as so in strict mode.
> The reason I reverted this temporarily is because myself and others have
> been seeing worse flagging since this went in.  I have had several people
> tell me that the flagging is worse for them in 0.18 than it was in 0.17
> and after I put this patch in, my flagging got worse as well. 

ok, i'll take your word for it
for me it got so good that i could actually turn autoskip on
for the first time without regretting it and turning it back off

> It partially 
> has to do with the stations you record.  I record a lot of shows off of CBS

CBS is probably the only station that worked better overall (b4 "the patch")

> here in the U.S. and CBS has an annoying habit of wanting me to see their
> logo as much as possible, so they display it on every blank frame and then
> turn it off when the commercial starts. 

so b4 marking otherwise blank frames with logos in them as blank.
it should be possible to check the some frames before and after them,
to make sure that a logo IS NOT in it 
for example check
(60th && 65th && 70th frame before) || (60th && 65th && 70th frame after) 
the blank frame with a logo in it.

i know this is all done in a frame by frame loop, so something more creative 
is needed. 

one could simply mark frames as BLANK or as BLANK_WITH_LOGO on the first pass. 
and later reflag BLANK_WITH_LOGO  as BLANK if that BLANK_WITH_LOGO  has 
frames with _no logo_ either shortly before it or shortly after it.

here's another bonus - this way you can kind of determine whether this is the 
start or the end of a break

who would have thought that leaving the logo up could in some way lead to more 
accurate detection :)

> I'm not 100% sure if this strictness is necessary if logo detection is
> working well enough, but I know 100% for sure that it breaks commercial
> detection with strict turned ON for lots of people here in the U.S. that
> record shows off certain stations.

i agree that it breaks,(fails to detect entire commercials) for some stations
but it does make it a lot better(100% correct) for a lot more stations
because it eliminates false positives for them.

i guess it  depends on whether most your shows use true blanks or not
I thought not using true blanks was an extreme rarity, and i was wrong :(

> I've hesitated in the past to add user-configurable settings to control
>  the flagging criteria, but am thinking that this is one that I want to
> add.

i saw it go in, thanks
i saw that it's still an undocumented one, which sounds right,
because this setting is only necessary until a better way to handle
blanks with logos can be conjured up.

> >I know, "better" is subjuective
> Right, that's the thing, you see the recordings you make, but since I've
> been working on this code for a couple years now and people know that,
> someone (or someones) usually let me know if it's taken a turn for the
> worse.  I'm not opposed to putting it back in, but I think it will be as
> an option as you also propose later in your post.

i guess i was overly optimistic
once i saw what a difference it made for me

> >Here's some objective stats from 50 recordings on my drive (long):
> >--for the 10% shows that leave it up at the start of a commercial--
> >    -it still detects "100%" correctly 99% of the time
> >     since the end is all that matters for a skip
> >       -it just won't auto skip
> >       -you have to hit 'z'(once or twice)
> 'Twice' means it wasn't 100%. :)

sometimes it's been 'twice'
because i have been too lazy to increase the number of seconds that you can be 
away from the beginning of a commercial, and still have the  "z" key skip to 
the end of the commercial

> I don't understand how you could have 100% accurate detection if the
> stations really leave the logo up?  

this is if they leave it up for the start of a commercial
but have true blanks for end of the commercial

> Since the blocks are based off of blank 
> frames, and the logo would cause the frames to not be detected as blank,
> then you would not be getting the blocks defined that you need so flagging
> would be off.  

ok - let me try to be more clear:
1) 80% of shows on my drive use "true blanks"
    you are saying this is a far smaller percenatge for you and others :((
- allowing logos in blanks
  breaks detection badly for these shows when 
  actors in dark coats walk right in front of the camera, etc
  temporarily  "blanking" the scene
     - as you mentioned, logo and scene change detection
       should help here but they seem not to
     - it seems that for me the logo and scene change detection are great
       for scoring the frame blocks and they never miss,
       but _only if_ the blanks were correctly detected in the first place.

2) 10% of the shows leave the blank up for START of commercial 
     and bring it up late, after end of commercial
     (i.e. the comm break _DOES_ end with a true blank!!)
- this is a facinating case !!
- you are right that the start does not get detected correctly
    -the first true blank (or reasonably dim) frame inside a commercial break
     is detected as the "start" of a commercial break
- but the end of every commercial gets detected correctly!
    -so hitting 'z' works fine
     (unless the start was detected "too far" into the commercial)
     you see why i have had to hit z twice on occasion?
- bottom line - i consider it 100% correct because
  a) no false positives
  b) all you have to do is: hit 'z'  and you are past the commercial

2) 10% of the shows on my drive put the blank up at END of commercial 
    this is mostly CBS, as you said
- this is where
    -the FIRST true blank/dim frame inside a commercial break
     is detected as the "start" of a commercial break
    -the LAST true blank/dim frame inside a commercial break
     is detected as the "END" of a commercial break
- these true blanks are usually in between actual commercials
    -so i end up watching the first and last commercial
     (or only the last, if i hit 'z' and skip the first one)
- still no false positives
    -since no frames of a show are missing the logo
     it can't cut to commercial too early or come  back too late
      (assuming reasonably bright logos) 
     WAF goes through roof.
-it has missed flagging some commercials for these shows altogether
    -ie there were not at least two true blanks inside a commercial break
    -do you also see this? ie completely not flagging some commercials
     WAF comes down to earth
> >--for the other 10% of shows that leave it up at the end--
> >    -it detects 100% correctly only 5% of the time
> >    -it comes back too early 90% of the time which is good
> >     (because of the scenechange and logo detection routines)
> And this is the case with some stations here, it comes back early
> because the blank frame between commercials didn't have the logo.

    -that's the price i'm willing to pay right now, 
     to have 80% of my shows detect 100% and have no false positives

> I think if the logo detection is accurate, the need for this option
> is lower.  If logo detection is working right, there shouldn't be (m)any
>  frames falsely detected as blank just because there is something that
> happens to be in that small logo area that isn't a logo while the rest of
> the screen is dark.

that's not really the problem though

i find that actually 
"having the _logo_ there, while the rest of the scene is blank" 
is pretty much the only thing that triggers false positives with cvs as it is 

> >On the other hand,
> >Not requiring blank frames to be totally blank gets lots of false
> > positives
> I'd be interested to see the frameInfo map for these cases, does it really
> detect a lot of dark frames as blank because they are blank except for
> some small object in the logo area?  That would be kind of odd.  Is this
> MST3K with the robots in the bottom corner of the video? :)

shows like "charmed" and "voyager" are dark enough that often the logo is the 
brightest part of a frame. so if you do a maxbright-minbright, without 
looking in the logo area, it thinks it's a blank frame (with current cvs)

until i patched the all method the way i did, i never got more than half the 
commercials crrect in those two shows, but like 5 false positves per show was 
not out of the question (ie goto commercial too early or come back too late)

with the patch for strict detection, that went in to 18, those shows detect so 
well that i could run a user job that converts commaps to cutlists with 100% 

so my questions to you:
1) did it get much better for shows that use true blanks? 
    or was it already 100%
2) did the number of false positives go down for shows that leave logo up?
i geuss it doesn't really matter,
 as both methods have their upsides and downsides as it is right now, 
where you have to optimize for either true blanks or for blanks with logos
> >====
> >ie according to my empirical observations
> >(it's pretty sad how much time i spent on this - easily 8 hours)
> >it's 18 times worse to allow logos on "blank frames"
> >====
> I'm not following this.  If the other 95% of the frame is blank and we're
> just not checking the 5% that the logo should be in, how can it be causing
> that many false positives?  This is almost the same as not checking the
> border area.

-there are tons of shows that i watch that are doing dirty things like panning 
the camera quickly past a black pillar or something like that so the frame 
temporarily blanks and the only thing that's up is the logo
-some shows use black frames to go from on scene to another, again the logo is 
the only thing in the frame.

> I appreciate the time you've spent in this and explaining things and think
> that will be helpful, 

you're welcome,  thanks for listening

I think it's always the ppl for whom a new way works worse that usually say 
something, and that the new way must have made it better for someone other 
than me :), but since it _does_ make it worse for quite a few people, i think 
we can work out something that makes it (close to) 100% for everybody

> but I must not be seeing the false positive blank 
> frames to the extent you're seeing them.

i guess not, again, must depend on differences between what we watch

> >temporarily, maybe this should have its own setting
> >instead of depending on the strict setting
> >
> >something like
> >    blankCanHaveLogo =
> >              gContext->GetNumSetting("BlankCanHaveLogo", 0);
> I'm not opposed to something like this for now, but think we may be able
> to work around it a better way (that won't require the end user to tune
> anything).

i think so too
as i described above

> Maybe the logo area needs to be tighter like a pixel mask, and not a box. 
> OR, probably even better the code could check if a logo was present first
> then if the logo was present, we ignore the logo area during blank-frame
> detection. How does that sound?

i am not following this one

> >BUT
> >===
> >there's got to be a way to do a check for blank frames that have logos on
> > them to see if the 60th frame before or after it, also has a logo on it,
> > otherwise don't mark it as blank.
> I think that's a possiblity, but we'd need to check more than one frame
> since the logo detection isn't quite accurate enough right now. 

ya i thought of that too
it's not that it's not accurate, 
ppl in white shirts sometimes wash out a logo, so it doesn't stand out
so, sometimes it can't be accurate for every frame
> Another way to do this might be to have 2 flags per frame while scanning
> it.  One flag would indicate the logo area was blank/non-blank and the
> other would indicate the non-logo area was blank/non-blank.  

sounds like the blank_with_logo versus true_blank

> If the 
> non-logo area was blank and we think there's a logo on the frame, then
> we could check X frames before and after the frame we think is blank.  If
> the frames before have a logo and the ones after don't (or vice-versa)
> then that tells us we are on a transition frame between commercial and
> non-commercial and we mark the frame as blank.  

hey, this is _exactly_ what i was thinking

but we don't want to lose the directionality do we?
we could mark it as more than just blank
ie blank_possible_start or blank_possible_end

this could later come into play when scoring

something like
if breakStart is a blank_possible_start 
or fbp->end is blank_possible_end

then it's more likely that the block in between is a commercial

flagging true_blanks and blank_with_logo separately
has another added benefit:
  -better debug messages to see why detection broke down 
   and what it should have marked as a start or end

> This could all be done 
> at the beginning of the post-analysis phase since we'd have access to
> the 2 "blank" flags as well as the logo information for all frames.
> This is more complicated than the existing method but should be a lot
> more accurate.

I completely agree

This has been an interesting chat (thesis)
you have probably finished the changes in the time it took me to write this

> I didn't commit a patch to change the wording on the message at the top
> of the email, I figured I'd get your opinion on that before I committed
> anything.

the way you worded it the second  time is good enough i think

         QString("Ignoring blocks starting at frame %1 "
                 "with length %2, length is under minimum "
                 "comm block length of %3 seconds.")
                 .arg(fbp->start - breakStart)

Risto Treksler
Elkhorn Lodge
Banff, Alberta, Canada

More information about the mythtv-dev mailing list