Hello Thomas, > I'm attempting to write a small application that extracts the durations > from MPEG2 files. I've been looking at the documentation and the > samples, and have come up with a simple app that calls "mpeg2_parse()" > until it returns "STATE_GOP", and when it does, looks at the > "info->gop->*" members. > > I have two small problems: > > The first is that the gop information seems to be the current position > in the stream, which means that the only way I can read the entire > stream length is to read the entire file, and save the last result. > > The second problem I have is that some files don't seem to have a GOP > section. > > Is the total stream duration stored somewhere in the file? Not as far as I know. > If so, is there an easy method to extract it? I think you can compute the stream duration using the framerate information contained in the stream header, and the number of pictures in the stream. See the second line of the output of `mpeg2dec -vvvv <file.m2v>`:
5a S- --- --- - SEQUENCE MPEG2 [EMAIL PROTECTED] PROG 352x240 chroma 176x120 fps 29.97 maxBps 187500 vbv 135168 picture 352x240 display 352x240 pixel 1x1 [...] The code which prints this line is in trunk/src/dump_state.c, and the frame rate determination code is in trunk/libmpeg2/header.c (mpeg2_header_sequence). Regards, Lionel Debroux. ------------------------------------------------------------------------- This SF.net email is sponsored by the 2008 JavaOne(SM) Conference Don't miss this year's exciting event. There's still time to save $100. Use priority code J8TL2D2. http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone _______________________________________________ Libmpeg2-devel mailing list Libmpeg2-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/libmpeg2-devel