[mythtv] PATCH: Commercial detection/skip using blank frames

Chris Pinkham cpinkham at bc2va.org
Sat Feb 22 00:56:44 EST 2003


> I gave the patch that was sent to the list a try (haven't updated my CVS
> in a few hours). It seemed to work fairly well on FOX here in NYC. I was
> able to skip commercial breaks with 1 or 2 hits of the Z key. The
> biggest problem I have is that I have to wait about 5 seconds after the
> commercials start before I hit Z. If I hit Z too soon after the
> commercials start then it rewinds to the black frame just previous.

I made a quick patch to try to help debug problems like this.  If you'd
like to try it, take the attached patch and apply it to you source tree.
Then, before running mythfrontend, set an environment variable called
DUMP_BLANK_FRAMES to "1" or something.  This will cause mythfrontend to
scan through the whole file instead of playing it when you select a video
on the playback screen.  It will print out a bunch of stuff like this:

Jump : 1620
Blank: 1620 1621 1622
Jump : 78
Blank: 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710
Jump : 890
Blank: 2600 2601 2602 2603 2604 2605 2606 2607 2608
Jump : 4971

That is all the blank frames detected with the amount of non-blank space
between them listed on the "Jump" lines.  So, I can see a 30 second
commercial going from around frame 1700 to frame 2600 in this example.
If you can take that output and send it to me (not the list), then it
might help in honing the code to do a better job.

I did it to a recording I made a couple nights ago and can see where
they have a 20-second commercial in between two 30-second commercials.
That explains why my code isn't detecting the middle commercial because
it's a non-"standard" length.

This patch isn't meant for inclusion in CVS, just to help test/refine
the blank frame commercial skip detection code.

Chris

*****************************************************************************
** Chris Pinkham                  Linux v2.2.18, Sane v1.0.4, Cajun v3.0-8 **
** cpinkham at bc2va.org                          http://www.bc2va.org/chris/ **
*****************************************************************************
-------------- next part --------------
Index: libs/libmythtv/NuppelVideoPlayer.cpp
===================================================================
RCS file: /var/lib/cvs/MC/libs/libmythtv/NuppelVideoPlayer.cpp,v
retrieving revision 1.135
diff -u -r1.135 NuppelVideoPlayer.cpp
--- libs/libmythtv/NuppelVideoPlayer.cpp	22 Feb 2003 04:42:31 -0000	1.135
+++ libs/libmythtv/NuppelVideoPlayer.cpp	22 Feb 2003 05:44:04 -0000
@@ -2143,6 +2143,32 @@
 
         GetFrame(audiofd <= 0);
 
+        if (getenv("DUMP_BLANK_FRAMES"))
+        {
+            PauseVideo();
+            while (!GetVideoPause())
+                usleep(50);
+
+            int variance;
+            long long int last_blank = 0;
+            while(!eof)
+            {
+                GetFrame(1, true);
+                variance = GetFrameVariance(vpos);
+                if ( variance < 20 )
+                {
+                    if ( framesPlayed == ( last_blank + 1))
+                        cout << " " << framesPlayed;
+                    else
+                        cout << "\nJump : " << framesPlayed - last_blank
+                            << "\nBlank: " << framesPlayed;
+                    cout.flush();
+                    last_blank = framesPlayed;
+                }
+            }
+            cout << "\n";
+        }
+
         if (autocommercialskip)
             AutoCommercialSkip();
 


More information about the mythtv-dev mailing list