[mythtv] Questions for MPEG2 knowledgable folks

Cory Papenfuss papenfuss at juneau.me.vt.edu
Wed Oct 19 17:56:09 UTC 2005


 	I wouldn't call myself too knowlegable about MPEG2 stuff, but this 
is a fairly well-known issue with ivtv streams from the Hauppauge cards. 
When there's a glitch, it will drop frames and adjust the PTS to 
compensate.  It is especially prone to this on "dirty" signals like from 
an analog tape (no TBC is the most likely culprit).

 	I'm not sure of the best solution, but I rather like the idea of 
either converting to I-frames, or perhaps reencoding around the bad spot. 
This has other uses (e.g. "lossless" commercial cutting).  Subtle things 
become more important, though... like do you offset the PTS/DTS of 
everything after the first cut by the 4 minutes you removed?  What does 
the MPEG spec say about discontinuous PTS?

 	Basically MPEG2 was never meant to be edited... :)

-Cory

On Tue, 18 Oct 2005, Geoffrey Hausheer wrote:

> I am currently looking into MPEG2 processing again.
>
>  I got myself a ROKU HD 1000, which makes a very nice frontend
> capable of displaying HD, but it can only play MPEG2 streams, and even
> then it is quite picky.  It does fine on my ATSC streams, but I have
> some other TS streams that it really doesn't like.  I tried running
> replex on these streams, but it dies about 12mins in with a
> ring-buffer overflow.  However, the ROKU plays those 12 minutes (the
> output of replex) flawlessly.  I pulled out the mpeg stream parser I
> wrote 2 years ago, and checked out the original stream.  It turns out
> that there are 440 video frames missing in a 30 minute show (about 15
> sec).  I'm not sure whether these frames are not in the original
> transmission, or whether this is an artifact of the capture card that
> aquired them.  If these weren't corrected, the audio would be about 15
> seconds ahead of the video by the end of the program.  The reason myth
> has no issues with the videos (as far as I can tell) is that the PTS
> (presentation times) are skewed such that occasionally (not
> consistantly) the video is slowed down to compensate.  The roku
> doesn't seem to like this (and, as far as I can tell, it isn't allowed
> in the DVD (or strict MPEG) spec either).  The MPEG spec seems to say
> that while the PTS can be used to sync audio and video streams, video
> frames should occur at a fixed frame rate (unless changed via a SEQ
> header).  So to build a fully compliant stream, it appears I need to
> present the video at fixed a fixed frequency.  I could do this by
> inserting a redundant I-frame whenever the video is off by more than 1
> frame (I should in theory be able to be within 1/2 of a frame from the
> audio during these 'slow mo' periods.  However, (a) the video will
> appear to stutter slightly, which may be annoying, and (b) the video
> still won't be DVD compliant as the DVD spec requires a strict GOP
> with a fixed number of I/P/B frames per GOP.  Of course, (b) may be a
> non-issue, as the TS streams don't comply with the fixed GOP-size
> requirements (or resolution, though that could be dealt with perhaps)
> of the DVD spec anyway.
>  Anyhow,  I'm looking for ideas on how else to approach the problem.
> The only other thing I've thought of is to reencode sections of the
> audio at a slightly increased speed to keep it in line with the video.
> This would likely present the smoothest result, if I can learn how
> the pitch-corrected video code works.
>  Another thing I was wondering, as I'm not at all familiar with the
> actual mpeg2 encoding stuff, is whetehr there is any way to convert
> between I, P, and B frames without reencoding (i.e. losslessly).  I
> guess it depends on whether motion-estimation occurs before or after
> the macroblocks are decoded, but i'm really fuzzy on this stuff.  If
> this were possible, I could actually build a DVD compliant stream from
> my streams, which would be pretty cool.
>  Once I figure out a reasonable method, I'll likely try to
> incorporate it into mythtranscode, though with the job-queue, it may
> prove more advantageous just to keep it as a completely seperate app.
>
> _______________________________________________
> mythtv-dev mailing list
> mythtv-dev at mythtv.org
> http://mythtv.org/cgi-bin/mailman/listinfo/mythtv-dev
>

-- 

*************************************************************************
* Cory Papenfuss                                                        *
* Electrical Engineering candidate Ph.D. graduate student               *
* Virginia Polytechnic Institute and State University                   *
*************************************************************************



More information about the mythtv-dev mailing list