[mythtv] Test (crude) patch for commercial skipping

Larry Matter mythtv at matter.net
Mon Feb 17 10:18:34 EST 2003


Neat stuff.  I think that most commercials (in the US anyway) are in 30
second chunks.  I was thinking that once a commercial is "detected" that
you could skip ahead in the stream by about 20-25 seconds and then start
your detection again and maybe that would speed it up.

Maybe you are already doing that; I haven't looked at the code yet.

Larry


> Attached is a crude patch to help skip commercials.  It uses a little of
> Robert Kulagowski's code in NuppelVideoPlayer::FindCommercial() in
> NuppelVideoPlayer.cpp and adds functionality.
>
> When the user hits 'Z' while watching (delayed) LiveTV or a recorded
> program, the commercial skip code is run.
>
> Basically it picks X (currently 200) random pixels from the current
> frame and determines what is the variance for those X pixels.  If the
> variance is less than 20, it assumes the frame is blank (no color
> detection though).  Currently I have it hardcoded to assume the blank
> screen transition between commericials and the show is at least 10
> frames long. As a precaution, the code will only skip forward up to 4
> minutes at a time looking for the break.  It also should come out of
> skip mode if it encounters the end of the recorded video or it catches
> up to live TV.
>
> Currently the code still has to decode each frame since it is based upon
> detecting blank frames.  This means it's not an instantaneous jump to
> the end of a commercial break after you hit 'Z', but instead it may take
> up to 10-15 seconds to scan through the frames till it finds the break.
>
> I'm uploading this as something to stir discussion and for people to try
> out.  I don't expect it to be integrated into MythTV just yet.  I wanted
> to have a setting option to specify the minimum number of blank frames
> that should mark the transition but didn't code that yet since this is
> basically a proof of concept.
>
> I've tried this code with a couple of prerecorded (U.S.) TV shows and it
> seems to work pretty good.  I have seen a show though where the
> commercial <-> show transitions were not separated by but 1-2 frames of
> black so this code did not work for those.  The max frames skipped code
> kicked in and returned to normal play after skipping 4 minutes meaning I
> had to rewind about a minute to get back to the beginning of the show.
>
> I haven't thought of a way to look for breaks in reverse since there
> isn't a reverse version of GetFrame().
>
> Can people take a look at this and let me know what they think or if it
> works for them?  The patch is based upon CVS as of 11pm EST on
> 2/16/2003.
>
> Possible enhancements include:
>   - option in setup to set minimum number of blank frames to look for -
> option in setup to set maximum number of seconds to skip while looking
> - only look for black blank frames (ie, not totally white screen which
>     could cause false triggers)
>   - ability to scan backwards
>   - auto-detection of beginning of commercials and auto-skip
>   - show every X frames as video is skipped (currently video is paused)
> - better commercial detection (how do the VCRs do it???)
>
> Chris
>
> *****************************************************************************
> ** Chris Pinkham                  Linux v2.2.18, Sane v1.0.4, Cajun
> v3.0-8 ** ** cpinkham at bc2va.org
> http://www.bc2va.org/chris/ **
> *****************************************************************************





More information about the mythtv-dev mailing list