[mythtv] scheduling, starttime accuracy

Chris Pinkham cpinkham at bc2va.org
Fri Feb 13 08:24:41 UTC 2009

* On Thu Feb 12, 2009 at 01:02:23AM -0500, Daniel Kristjansson wrote:
> recording name that is then stuffed in ProgramInfo and used from then
> on, the recstarttime could subsequently be updated to the "correct" time
> later without negative consequences. (i.e. when the first byte is
> written to the RingBuffer.)

I think this is the big issue.  With differences in system speeds, tuner
cards, etc. and the possible drift of 1 second due to the 1 second accuracy
in the datetime field, it seems like you could still end up being 2-3
seconds off between systems recording from exactly the same station
either OTA or on satellite or cable.  You could put these 2 different
systems beside each other on the same antenna and you'd have differences
in the time that it takes to get the first byte to disk.  Then consider
what that first byte was.  Did they start recording at exactly the same
(key?)frame of video or were they off by a keyframe or two?

The only real way to make this accurate is to key off something in the
video itself such as a blank frame or scene change or aspect ratio
change, ie, the same things the commercial flagger looks for.
If you have 2 recordings of the same show that started X.Y
seconds apart from each other, you need to look for something unique
in those clips that can be used to sync them.   The programs that stitch
together photographs to make larger ones don't use GPS or timestamps to
know what picture can connect with another and where, they look at
the fingerprints of the pictures themselves.

I think one could get more accuracy out of running the commercial flagger
on the first X minutes of each file and then matching up the flags
(blank frame, aspect change, etc.) that the flagger found for each clip
to come up with a frame-accurate offset.  It wouldn't take long to run
the flagger code over a minute of video and get the flags.
This frame-based flag info along with a valid commercial skip (or cut) list
should be enough to use that skip list on another recording of the same
program from the same source.  This is very similar logic to what I had in
the original flagger.  The code searched for sets of blank frames that
were ~30 seconds apart.  In this scenario, you'd have the set of flags
from the first video, indicating something like a blank frame at
frames 15, 38, 104, and 135.  Then it's just a matter of finding blank
frames in the second video that are 23, 66, and 31 frames apart.  That
should get you near perfect alignment.  The algorithm for this would
be trivial and take probably only a second or two.  This could even be
done at playback time in the background if integrated correctly.  Given
the flag list from the first minute of the first video, the player could
scan the video for the flags itself and once it found the necessary
alignment offset, it could offset the skip/cutlist frame counts
accordingly in memory (and in the DB possibly).


More information about the mythtv-dev mailing list