src/main/java/org/jcodec/codecs/mpeg12/MPEGES.java
public MPEGPacket frame(ByteBuffer buffer) throws IOException {

        ByteBuffer dup = buffer.duplicate();

        while (curMarker != 0x100 && curMarker != 0x1b3 && skipToMarker())
            ;

        while (curMarker != 0x100 && readToNextMarker(dup))
            ;

        readToNextMarker(dup);

        while (curMarker != 0x100 && curMarker != 0x1b3 && readToNextMarker(dup))
            ;

        dup.flip();
        
        PictureHeader ph = MPEGDecoder.getPictureHeader(dup.duplicate());

        return dup.hasRemaining() ? new MPEGPacket(dup, 0, 90000, 0, frameNo++,
                ph.picture_coding_type <= MPEGConst.IntraCoded ? FrameType.KEY : FrameType.INTER, null) : null;
    }
public MPEGPacket frame(ByteBuffer buffer) throws IOException {

        ByteBuffer dup = buffer.duplicate();

        while (curMarker != 0x100 && curMarker != 0x1b3 && skipToMarker())
            ;

        while (curMarker != 0x100 && readToNextMarker(dup))
            ;

        readToNextMarker(dup);

        while (curMarker != 0x100 && curMarker != 0x1b3 && readToNextMarker(dup))
            ;

        dup.flip();
        
        PictureHeader ph = MPEGDecoder.getPictureHeader(dup.duplicate());

        return dup.hasRemaining() ? new MPEGPacket(dup, 0, 90000, 0, frameNo++,
                ph.picture_coding_type <= MPEGConst.IntraCoded ? FrameType.KEY : FrameType.INTER, null) : null;
    }
Reads one MPEG1/2 video frame from MPEG1/2 elementary stream into a
provided buffer.

@param buffer
A buffer to use for the data.
@return A packet with a video frame or null at for end of the stream. The
data buffer inside the packet will be a sub-buffer of a 'buffer'
provided as an argument.
@throws IOException