On Sat, 10 Dec 2005 05:45 am, Chris Pinkham wrote:
> >  - 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.

Will this ever be a mythtv-setup option, instead of undocumented?  Or better 
yet autodetected.

> >  - 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.

See attached commflag-svn_start_stop_times.patch.  This patch hasn't been 
compiled so probably has bugs. I'm not sure that the macro MAX is acceptable 
MythTV coding style.      

> 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.

I've dropped the second attempt at logo detection because during testing it 
wasn't any more successful.  It was actual worse on my test video.  Even a 
third test was useless.

> > 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.

See attached commflag-svn_format-aspect.patch.  This patch hasn't been 
compiled so probably has bugs.  I did test this on 18.1 and it works much 
better for my recordings.  Aspect changes untested because I don't have them.  
The difference in score due to frame block size is because the larger blocks 
are more meaningful for this test.  Are they?

> 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.

I did some basic image processing a uni but nothing like this.  Its hard for 
me to write code for svn when I'm using 18.1.

Thanks,
Paul
-- 
diff -ur mythtv-svn/programs/mythcommflag/ClassicCommDetector.cpp mythtv-svn-fix/programs/mythcommflag/ClassicCommDetector.cpp
--- mythtv-svn/programs/mythcommflag/ClassicCommDetector.cpp	2005-12-10 16:57:45.373031536 +1000
+++ mythtv-svn-fix/programs/mythcommflag/ClassicCommDetector.cpp	2005-12-10 19:42:21.471636336 +1000
@@ -8,6 +8,8 @@
 #include "libmyth/mythcontext.h"
 #include "libmythtv/programinfo.h"
 
+#define MAX(a,b) ((a)>(b)?(a):(b))
+
 // This is used as a bitmask.
 enum SkipTypes {
     COMM_DETECT_OFF         = 0x00,
@@ -43,12 +45,16 @@
                                          bool showProgress_in,
                                          bool fullSpeed_in,
                                          NuppelVideoPlayer* nvp_in,
+                                         const QDateTime& startedAt_in,
+                                         const QDateTime& stopsAt_in,
                                          const QDateTime& recordingStartedAt_in,
                                          const QDateTime& recordingStopsAt_in) :
         commDetectMethod(commDetectMethod_in),
         showProgress(showProgress_in),
         fullSpeed(fullSpeed_in),
         nvp(nvp_in),
+        startedAt(startedAt_in),
+        stopsAt(stopsAt_in),
         recordingStartedAt(recordingStartedAt_in),
         recordingStopsAt(recordingStopsAt_in),
         framesProcessed(0)
@@ -248,7 +254,7 @@
     
     int requiredHeadStart = 30;
     if (commDetectMethod & COMM_DETECT_LOGO)
-        requiredHeadStart += commDetectLogoSecondsNeeded;
+        requiredHeadStart += MAX(0,recordingStartedAt.secTo(startedAt)) + commDetectLogoSecondsNeeded;
     else
         requiredHeadStart += 30;
 
@@ -1136,7 +1142,9 @@
     {
         for (int i=0;i<COMM_FORMAT_MAX;i++) formatCounts[i]=0;
 
-        for(long long i = 0; i < framesProcessed; i++ )
+        for(long long i = (MAX(0,recordingStartedAt.secTo(startedAt))*(long)fps); 
+                i < (framesProcessed - (MAX(0,stopsAt.secTo(recordingStopsAt))*(long)fps));
+                i++ )
             formatCounts[frameInfo[i].format]++;
 
         for(int i = 0; i < COMM_FORMAT_MAX; i++)
@@ -2538,7 +2546,7 @@
         nvp->DiscardVideoFrame(nvp->GetRawVideoFrame(0));
 
         loops = 0;
-        seekFrame = seekIncrement;
+        seekFrame = MAX(0,recordingStartedAt.secTo(startedAt)) + seekIncrement;
 
         while(loops < maxLoops && !nvp->GetEof())
         {
diff -ur mythtv-svn/programs/mythcommflag/ClassicCommDetector.h mythtv-svn-fix/programs/mythcommflag/ClassicCommDetector.h
--- mythtv-svn/programs/mythcommflag/ClassicCommDetector.h	2005-12-08 20:47:56.693571760 +1000
+++ mythtv-svn-fix/programs/mythcommflag/ClassicCommDetector.h	2005-12-10 18:02:00.924898560 +1000
@@ -12,6 +12,8 @@
     public:
         ClassicCommDetector(int commDetectMethod, bool showProgress,
                             bool fullSpeed, NuppelVideoPlayer* nvp,
+                            const QDateTime& startedAt,
+                            const QDateTime& stopsAt,
                             const QDateTime& recordingStartedAt,
                             const QDateTime& recordingStopsAt_in);
         virtual ~ClassicCommDetector();
@@ -94,6 +96,7 @@
         bool showProgress;
         bool fullSpeed;
         NuppelVideoPlayer *nvp;
+        QDateTime startedAt, stopsAt;
         QDateTime recordingStartedAt, recordingStopsAt;
         bool stillRecording;
         QMap<long long,int> lastSentCommBreakMap;
diff -ur mythtv-svn/programs/mythcommflag/CommDetectorFactory.cpp mythtv-svn-fix/programs/mythcommflag/CommDetectorFactory.cpp
--- mythtv-svn/programs/mythcommflag/CommDetectorFactory.cpp	2005-06-24 21:03:42.347883080 +1000
+++ mythtv-svn-fix/programs/mythcommflag/CommDetectorFactory.cpp	2005-12-10 18:00:39.117335200 +1000
@@ -8,6 +8,8 @@
     CommDetectorFactory::makeCommDetector(int commDetectMethod,
                                           bool showProgress, bool fullSpeed,
                                           NuppelVideoPlayer* nvp,
+                                          const QDateTime& startedAt,
+                                          const QDateTime& stopsAt,
                                           const QDateTime& recordingStartedAt,
                                           const QDateTime& recordingStopsAt)
 {
@@ -16,7 +18,8 @@
 		//Future different CommDetect implementations will be created here.
         default:
 			return new ClassicCommDetector(commDetectMethod, showProgress,
-                                           fullSpeed, nvp, recordingStartedAt,
+                                           fullSpeed, nvp, startedAt,
+                                           stopsAt, recordingStartedAt,
                                            recordingStopsAt);
 	}
 	
diff -ur mythtv-svn/programs/mythcommflag/CommDetectorFactory.h mythtv-svn-fix/programs/mythcommflag/CommDetectorFactory.h
--- mythtv-svn/programs/mythcommflag/CommDetectorFactory.h	2005-06-24 21:03:42.333885208 +1000
+++ mythtv-svn-fix/programs/mythcommflag/CommDetectorFactory.h	2005-12-10 18:03:34.040742800 +1000
@@ -25,8 +25,10 @@
 
 	CommDetectorBase* makeCommDetector(int commDetectMethod, bool showProgress,
                                        bool fullSpeed, NuppelVideoPlayer* nvp,
+                                       const QDateTime& startedAt,
+                                       const QDateTime& stopsAt,
                                        const QDateTime& recordingStartedAt,
-                                       const QDateTime& recordingStopsAt_in);
+                                       const QDateTime& recordingStopsAt);
 };
 
 #endif
.diff -Nur mythtv-svn/programs/mythcommflag/ClassicCommDetector.cpp mythtv-svn-fix/programs/mythcommflag/ClassicCommDetector.cpp
--- mythtv-svn/programs/mythcommflag/ClassicCommDetector.cpp    2005-12-10 19:49:42.171639752 +1000
+++ mythtv-svn-fix/programs/mythcommflag/ClassicCommDetector.cpp        2005-12-10 19:57:21.069876616 +1000
@@ -1134,7 +1134,7 @@
     }
     else
     {
-        for (int i=0;i<COMM_FORMAT_MAX;i++) formatCounts[i]=0;
+        memset(&formatCounts, 0, sizeof(formatCounts));

         for(long long i = 0; i < framesProcessed; i++ )
             formatCounts[frameInfo[i].format]++;
@@ -1310,6 +1310,14 @@
                 }
             }

+            if ((!decoderFoundAspectChanges) && (fbp->formatMatch < (fbp->frames * .10)))
+            {
+                if (verboseDebugging)
+                    VERBOSE(VB_COMMFLAG, "      < 10% of frames match show "
+                            "letter/pillar-box format, -20");
+                fbp->score -= 20;
+            }
+
             if ((abs((int)(fbp->frames - (15 * fps))) < 5 ) ||
                 (abs((int)(fbp->frames - (30 * fps))) < 6 ) ||
                 (abs((int)(fbp->frames - (60 * fps))) < 8 ))
@@ -1334,6 +1342,14 @@
                             " == 0, -10");
                 fbp->score -= 10;
             }
+
+            if ((!decoderFoundAspectChanges) && (fbp->formatMatch < (fbp->frames * .10)))
+            {
+                if (verboseDebugging)
+                    VERBOSE(VB_COMMFLAG, "      < 10% of frames match show "
+                            "letter/pillar-box format, -10");
+                fbp->score -= 10;
+            }

             if (fbp->ratingCount > (fbp->frames * 0.25))
             {
@@ -1344,71 +1360,12 @@
             }
         }

-        if (decoderFoundAspectChanges)
-        {
-            if (fbp->aspectMatch > (fbp->frames * .90))
-            {
-                if (verboseDebugging)
-                    VERBOSE(VB_COMMFLAG, "      > 90% of frames match show "
-                            "aspect, +10");
-                fbp->score += 10;
-
-                if (fbp->aspectMatch > (fbp->frames * .95))
-                {
-                    if (verboseDebugging)
-                        VERBOSE(VB_COMMFLAG, "      > 95% of frames match show "
-                                "aspect, +10");
-                    fbp->score += 10;
-                }
-            }
-            else if (fbp->aspectMatch < (fbp->frames * .10))
-            {
-                if (verboseDebugging)
-                    VERBOSE(VB_COMMFLAG, "      < 10% of frames match show "
-                            "aspect, -10");
-                fbp->score -= 10;
-
-                if (fbp->aspectMatch < (fbp->frames * .05))
-                {
-                    if (verboseDebugging)
-                        VERBOSE(VB_COMMFLAG, "      < 5% of frames match show "
-                                "aspect, -10");
-                    fbp->score -= 10;
-                }
-            }
-        }
-        else if (format != COMM_FORMAT_NORMAL)
+        if (decoderFoundAspectChanges && (fbp->aspectMatch < (fbp->frames * .10)))
         {
-            if (fbp->formatMatch > (fbp->frames * .90))
-            {
-                if (verboseDebugging)
-                    VERBOSE(VB_COMMFLAG, "      > 90% of frames match show "
-                            "letter/pillar-box format, +10");
-                fbp->score += 10;
-
-                if (fbp->formatMatch > (fbp->frames * .95))
-                {
-                    if (verboseDebugging)
-                        VERBOSE(VB_COMMFLAG, "      > 95% of frames match show "
-                                "letter/pillar-box format, +10");
-                    fbp->score += 10;
-                }
-            }
-            else if (fbp->formatMatch < (fbp->frames * .10))
-            {
-                if (verboseDebugging)
-                    VERBOSE(VB_COMMFLAG, "      < 10% of frames match show "
-                            "letter/pillar-box format, -10");
-                fbp->score -= 10;
-
-                if (fbp->formatMatch < (fbp->frames * .05))
-                {
-                    if (verboseDebugging)
-                        VERBOSE(VB_COMMFLAG, "      < 5% of frames match show "
-                                "letter/pillar-box format, -10");
-                    fbp->score -= 10;
-                }
-            }
+            if (verboseDebugging)
+                VERBOSE(VB_COMMFLAG, "      < 10% of frames match show "
+                        "aspect, -20");
+            fbp->score -= 20;
         }

         msg.sprintf("  NOW %3d:%02d %6ld %6ld %6ld %7.2f %3d %6d %6d %6d "
_______________________________________________
mythtv-dev mailing list
[email protected]
http://mythtv.org/cgi-bin/mailman/listinfo/mythtv-dev

Reply via email to