GOPchop will do this for you. I designed it using kfir streams, so I think most of the bugs are worked out. Check:
gopchop.sourceforge.net I haven't found a single decoder that actually pays attention to the "broken_link" flag. I find this _highly_ irritating. Since GOPs are optional headers, I assume that these decoders are just cutting corners and ignoring the GOPs. To solve this problem in GOPchop, I would do two things: the "correct" thing, which is setting the "broken_link" flag, and then I actively remove all the B-frames from the video stream that follow the first I-frame. This appears to totally do the trick. I also set the "closed" bit, since now the GOP is closed. Can you share your code with us? In my most recent CVS, I wrote "mpegcat" which will spit out all kinds of information about an MPEG2-PS file, reporting locations, sizes, and flags of all the headers. On Wed, Feb 06, 2002 at 02:12:21PM +0000, MAL wrote: > This is a last call for aid... > I am trying to cut sections from an MPEG2 generated by a KFir. > By my understanding, the KFir uses bi-directional frame coding (IBP), as > opposed to progressive frame coding, which makes cutting the files at > clean boundaries very hard. > I need to be able to cut a file into sections, (for burning to cd > progressively), and those sections need to be sequential without loss. > > I have written a program to almost completely dissect an MPEG2, > (everything bar decoding the actual pictures), and output a section, but > regardless of whether I set the group of pictures' header's > 'broken_link' flag, I still get corrupt starts to the beginning of my > sections. The closed_gop flag within the mpeg2 is set, meaning the fkir > doesn't encode cleanly cuttable group_of_pictures. > > Does anyone know of a way I can "fix" the mpeg2 to have cleanly cuttable > boundaries, or will I need to re-encode the whole file? > > _Any_ help on this subject would be great, I refuse to believe there is > no way to do it :) > > Also, if anyone knows whether you can get the KFir to encode > differently, shout me pls. > > All the best, > > MAL > Komcept Solutions Ltd. > United Kingdom > -- Kees Cook @outflux.net