def METHOD_NAME(inputData, initialPts):
	programPID = None
	videoPids = []
	packetStartBuffer = []
	markerBuffer = ''
	state = WAIT_MARKER
	lastPesPos = None
	curStartPos = None
	keyFrame = None
	result = []
	for packetStart in xrange(0, len(inputData), TS_PACKET_LENGTH):
		curPacket = buffer(inputData, packetStart, TS_PACKET_LENGTH)
		# skip the TS header
		curPos = 4	# sizeof ts header
		# skip the adaptation field
		if ord(curPacket[3]) & 0x20: # adaptationFieldExist
			curPos += 1 + ord(curPacket[curPos])
		pid = ((ord(curPacket[1]) & 0x1f) << 8) | ord(curPacket[2])
		if pid == PAT_PID:
			programPID = getPmtPidFromPat(curPacket, curPos)
		elif pid == programPID:
			videoPids = getVideoPidsFromPmt(curPacket, curPos)
		elif pid in videoPids:
			if ord(curPacket[1]) & 0x40:	# payloadUnitStartIndicator
				# get the pts value
				lastPesPos = packetStart
				lastPtsValue = None
				curPos += 6
				thePesOptHeader = pesOptionalHeader.parse(curPacket[curPos:])
				curPos += pesOptionalHeader.sizeof()
				if thePesOptHeader.ptsFlag:
					ptsStruct = pts.parse(curPacket[curPos:])
					lastPtsValue = getPts(ptsStruct)
					curPos += pts.sizeof()
					if thePesOptHeader.dtsFlag:
						curPos += pts.sizeof()
			if len(curPacket[curPos:]) == 0:
				continue
			# process the video stream
			curBuffer = markerBuffer + curPacket[curPos:]
			splittedBuffer = curBuffer.split('\x00\x00\x01')
			for curIndex in xrange(1, len(splittedBuffer)):
				if len(splittedBuffer[curIndex]) == 0:
					continue
				nalType = ord(splittedBuffer[curIndex][0]) & 0x1f
				if nalType == NAL_IDR_SLICE:
					keyFrame = True
				if nalType == NAL_AUD:
					if not curPacket[curPos:].startswith('\x00\x00\x00\x01\x09'):
						if curIndex == 1 and len(splittedBuffer[0]) < len(packetStartBuffer):
							curEndPos = packetStartBuffer[len(splittedBuffer[0])] + TS_PACKET_LENGTH
						else:
							curEndPos = packetStart + TS_PACKET_LENGTH
					if keyFrame:
						if initialPts == None:
							initialPts = curPts
						result.append((curPts - initialPts, curStartPos, curEndPos - curStartPos))
					curStartPos = lastPesPos
					curPts = lastPtsValue
					keyFrame = False
			markerBuffer = curBuffer[-3:]
			packetStartBuffer = packetStartBuffer + [packetStart] * min(len(curPacket[curPos:]), 4)
			packetStartBuffer = packetStartBuffer[-4:]
			curEndPos = packetStart + TS_PACKET_LENGTH
	if keyFrame:
		if initialPts == None:
			initialPts = curPts
		result.append((curPts - initialPts, curStartPos, curEndPos - curStartPos))
	return (initialPts, result)