[mythtv] Incorrect frame counts

William Uther willu.mailingLists at cse.unsw.edu.au
Sat Mar 12 06:00:08 UTC 2005


Hi,
   I'm trying to debug this timing problem I see with TS DVB recording.  
I'm getting a little lost in this code because I don't know what it is 
supposed to be doing (my first look at the real guts of myth).  I was 
wondering if someone out there might be able to give me a few 
pointers...

Here is what I've found so far:  (starting at symptoms and trying to 
work back to causes)

Watching a show that is still being recorded:

If I modify NuppelVideoPlayer::calcSliderPos to output both the 'frames 
written' and the 'frames played', then I see that on the channels that 
behave strangely, framesWritten is ticking over five times slower than 
framesPlayed.  On the channels that work, they tick over in sync.  
video_frame_rate is correct at 25.

I then started trying to follow framesWritten backwards to see where it 
came from.  I think the original source is 
DTVRecorder::FindKeyframes().  (passed using the variable 
_frames_written_count to DTVRecorder::GetFramesWritten(), then through 
a series of similarly named wrapper functions out to calcSliderPos().)

If I modify DTVRecorder::FindKeyframes by turning on 
DEBUG_FIND_KEY_FRAMES, and also add an extra debug statement that is 
written out for every picture start code (lines labelled 'all'), then 
the working channels generate this debug output:

2005-03-12 15:00:34.384 GOP sc(491) wc(480) lgop(479) lseq(0)
2005-03-12 15:00:34.385 all sc(492) wc(481) lgop(491) lseq(0)
2005-03-12 15:00:34.432 all sc(493) wc(482) lgop(491) lseq(0)
2005-03-12 15:00:34.462 all sc(494) wc(483) lgop(491) lseq(0)
2005-03-12 15:00:34.513 all sc(495) wc(484) lgop(491) lseq(0)
2005-03-12 15:00:34.544 all sc(496) wc(485) lgop(491) lseq(0)
2005-03-12 15:00:34.597 all sc(497) wc(486) lgop(491) lseq(0)
2005-03-12 15:00:34.628 all sc(498) wc(487) lgop(491) lseq(0)
2005-03-12 15:00:34.672 all sc(499) wc(488) lgop(491) lseq(0)
2005-03-12 15:00:34.703 all sc(500) wc(489) lgop(491) lseq(0)
2005-03-12 15:00:34.754 all sc(501) wc(490) lgop(491) lseq(0)
2005-03-12 15:00:34.784 all sc(502) wc(491) lgop(491) lseq(0)
2005-03-12 15:00:34.831 all sc(503) wc(492) lgop(491) lseq(0)

12 picture frames for every key frame.  I didn't see any seq header 
output.

The broken channels look like this:

2005-03-12 14:59:19.386 GOP sc(28) wc(27) lgop(27) lseq(0)
2005-03-12 14:59:19.386 all sc(29) wc(28) lgop(28) lseq(0)
2005-03-12 14:59:19.866 GOP sc(29) wc(28) lgop(28) lseq(0)
2005-03-12 14:59:19.866 all sc(30) wc(29) lgop(29) lseq(0)
2005-03-12 14:59:20.354 GOP sc(30) wc(29) lgop(29) lseq(0)
2005-03-12 14:59:20.393 all sc(31) wc(30) lgop(30) lseq(0)
2005-03-12 14:59:20.824 GOP sc(31) wc(30) lgop(30) lseq(0)
2005-03-12 14:59:20.824 all sc(32) wc(31) lgop(31) lseq(0)

Only one picture frame for each key frame.

Is it possible that there are other picture frames, undetected by 
FindKeyframes(), that the player is picking up?

My current working theory is that the TS recording code has a very 
simple parser in it to detect frames, and this parser is simply not 
detecting all the frames.  Does this sound plausible?  I know very 
little about MPEG.  How would I go about checking this?

Then I started looking at what happened with a pre-recorded show.  With 
this sort of show, NuppelVideoPlayer::calcSliderPos() relies upon 
knowing the totalLength of the video.  This is set in SetFileLength() 
which I was guessing was called by DecoderBase::SyncPositionMap().  
That function gets the file length from the last entry in the position 
map in the database.  It also multiplies by 'keyframedist'.  I don't 
understand keyframedist very well yet.

This suggested that using mythcommflag to re-build the seek table might 
be a work-around.  It seems to get frames by playing the video, and 
seeing as normal playback can count frames ok (it is the recorder that 
is broken), this might fix things.  As has already been noted on this 
list, it doesn't seem to fix the problem.  I haven't started looking 
into why.

Thanks for any insight,

Will            :-}

--
Dr William Uther                           National ICT Australia
Phone: +61 2 9385 6357               Computer Science and Engineering
Email: willu at cse.unsw.edu.au          University of New South Wales
Web: http://www.cse.unsw.edu.au/~willu/     Sydney, Australia



More information about the mythtv-dev mailing list