[mythtv] alternative method for commercial skipping

Chris Pinkham cpinkham at bc2va.org
Thu May 15 18:20:17 EDT 2003


> In the place where I live (The Netherlands) we do not have the  blank 
> screens before and after the commercials, but there is another way to find 
> out if there are commercials on the screen: All channels are so kind to 
> display a logo/icon in a corner of the screen when a program is showing, 


This is _not_ in current CVS but should be later tonight.
Over the past couple day, I have reworked a major portion of the
commercial skip/detection code.  I did a few things:

* Moved the functions inside commercial_skip.cpp into a CommDetect class
	and modified all files that use the commercial detection code to use
	the new class.  The simplest usage is like this:

	- create a CommDetect object giving the frame size and frame_rate
		CommDetect *commDetect = new CommDetect(640, 480, 29.97);
	- turn off/on blank frame detection (defaults to on in object)
		commDetect->SetBlankFrameDetection(false);
	- turn on/off scene change detection (defaults to off in object)
		commDetect->SetSceneChangeDetection(true);
	- loop through feeding each frame to be processed along with frame number
		commDetect->ProcessNextFrame(vbuffer[vpos], framesPlayed);
	- retrieve blank frame map if wanted (to save to the database)
		commDetect->GetBlankFrameMap(blankMap);
	- retrieve commercial break map if wanted (to save to the database)
		commDetect->GetCommBreakMap(commBreakMap);

The user will now have the ability to choose from 3 different detection
methods:

	- Blank Frame (current method using only blank frames)
	- Blank Frame + Scene Change (current method plus uses scene change
	  information to try to fill in gaps that look like potential commercials.
	- Scene Change (uses only scene change rate information to try to
	  determine where commercials start/end.  this assumes commercials have
	  a higher rate of scene change than regular show content does)

With the new structure, adding more detection methods should be pretty
easy.  The ProcessNextFrame() function runs the required detection
routines against the frame that is passed in.  I plan on adding logo
and still-frame detection methods in the future as well as adding some
way to analyze the audio looking for silence at scene changes as well
as abrupt volume changes which might indicate commercial cuts.

Anyway, I have been testing this on my system some yesterday and today and
should get this committed to CVS tonight.  I'd like to get some feedback
on whether the scene change stuff works for anyone else as a standalone
method in places where blank frame detection doesn't work.

As an enhancement to blank frame detection, the scene change detection
helps in places like the very beginning of a recording where there
is a short cutoff part of a commercial followed by a full commercial.
The blank frame code doesn't pick up the short blurb since it's not
a normal commercial length.  With the scene change detection, the
code can now look at that short blurb and determine that since there
is a high rate of scene change during that period and it is immediately
followed by a commercial then the short blurb is probably a commercial
as well.  This is one example of how they can work together.

The current scene change code uses a histogram to determine whether the
scene has changed.  I've seen several papers on the net about logo
detection and think localized histograms could also be useful as well.
I'll probably tackle logo detection sometime soon.  I did have code
working a while ago that would detect the rating symbol that stations
here in the U.S. have to put up at the beginning of a show, so that
will come in handy for detecting logos.  Still frame detection will
be easy as well.  Ie, if the last X frames were the same, then assume
still-frame and mark that spot.  Then look for marks which are
certain distances apart (such as a 30-second commercial just like the
blank frame code works now).

Chris


More information about the mythtv-dev mailing list