[mythtv] Questions for MPEG2 knowledgable folks

Cory Papenfuss papenfuss at juneau.me.vt.edu
Thu Oct 20 17:20:06 UTC 2005


>>         Is the behavior of a playback device defined for when this
>> happens?  I'd only heard of applying to broken bit when a GOP gets mangled
>> (e.g. non-keyframe editing).
> It is my understanding that you set the 'broken bit' to ignore any
> B-frames which would be presented before the 1st I-frame after a GOP.
> This happens when you have discontinuity between two GOPs (i.e. you
> chopped out info).  At this time, PTS can jump without any side
> effects.
>
 	... or any after a missing I-frame if the GOPs are open. 
Basically, just that a reference frame is missing for either a P or B. 
That is a different issue than a PTS jump (although they may be dealt with 
the same as you suggest).

>>         There's open vs. closed GOPs, as well as different GOP structures.
>> I didn't think that DVD-compliance implied either of those, however... I
>> thought that open/closed and variable-length GOP structures were OK.
>> Maybe it's just that the settop players are often tolerant of them and
>> I've never noticed.
> Well, MPEG2 (unlike MPEG1) doesn't actually require a GOP at all.
> However, DVD does.  I don't have a DVD spec around, but as I recall,
> the GOP on a DVD must comprise:
> IBBPBBPBBPBBPBB
>
 	I'm pretty sure that I've seen commericial DVDs that have variable 
GOP structure.  I'll believe that the DVD standard requires a GOP whereas 
vanilla MPEG2 may not, but I have a hard time believing that it specifies 
a *specific* structure:
http://en.wikipedia.org/wiki/MPEG-2
http://www.absoluteastronomy.com/encyclopedia/m/mp/mpeg-23.htm
 	They give a *maximum* GOP length (18-NTSC/15-PAL), but don't 
indicate a required structure.  This:
http://dvd-hq.info/Compression.html
 	implies that there is one for multi-angle disks.  Maybe that was 
it?
 	In any event, given that we're talking about trying to fix broken 
frames here and there, the additional benefit open GOPs and adaptive GOP 
size (i.e. "scene change" detection) would be really good to implement. 
I've seen some links that imply that ivtv may be capable of doing it.  I'm 
pretty sure that it's NOT now... I've seen some horribly stupid 
"decisions" on some recorded streams.  For instance... ending a GOP and 
staring another with a I-frame *in between fields* of a scene change on an 
interlaced capture.

 	That's why I transcode any material that I'm planning on archiving 
to DVD.  The quality/bitrate of RAW captures is pretty poor.  I generally 
can resize/transcode from a 640x480 5 Mbps capture to a 352x480 3-3.5 
Mbps adaptive GOP, denoised output with very little quality loss.

> Well, fixing GOPs are easy (sort of).  A GOP MUST start (streamwise
> not temporally) with an I-frame, assuming I frames come at a
> reasonable frequency, the GOPs can be set to be  correct from an MPEG2
> persepctive.  The problem is again DVD-compliance, and for that, you
> need an I-frame every 15 frames (to my kowledge), which implies frame
> conversion.  Note that even if frame conversion (without reencoding)
> is possible, the video quality will be identical to what you have now.
> If the B-frame prediction was off, converting a B-frame to an I-frame
> would capure that 'badness'.  Anyhow, this is all speculation at this
> point.  I either need to learn how the video encoding works, or wait
> for someone to chime in who has enough knoledge.  What I can do is to
> ensure that A/V ES are in sync, so demuxing/remuxing works, and that
> is what I'm working on.
>
 	So you're planning on padding and/or discarding mis-matched A and 
V stream frames?

> Well, they will (hopefully) be standard MPEG2 streams, though not
> DVD-compliant. But I'm not looking for DVD-compliance right now. It
> looks like it is likely an intractable problem (unless frame
> conversion is possible, or we pay the price of a reconversion).
>
> I could make a much more informative statement if I had any
> documentation about DVD requirements, but I don't.
>
 	I still think a partial reconversion would be a great compromise. 
ONLY reencode (even it's a full decode/reencode of an entire GOP) around 
glitches in the stream or commercial cuts.

-Cory

-- 

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



More information about the mythtv-dev mailing list