def isTS(self, file):
        file.seek(0, 0)

        buffer = file.read(TS_PACKET_LENGTH * 2)
        c = 0

        while c + TS_PACKET_LENGTH < len(buffer):
            if indexbytes(buffer, c) == indexbytes(buffer, c + TS_PACKET_LENGTH) == TS_SYNC:
                break
            c += 1
        else:
            return 0

        buffer += file.read(10000)
        self.type = 'MPEG-TS'

        while c + TS_PACKET_LENGTH < len(buffer):
            start = indexbytes(buffer, c + 1) & 0x40
            # maybe load more into the buffer
            if c + 2 * TS_PACKET_LENGTH > len(buffer) and c < 500000:
                buffer += file.read(10000)

            # wait until the ts payload contains a payload header
            if not start:
                c += TS_PACKET_LENGTH
                continue

            tsid = ((indexbytes(buffer, c + 1) & 0x3F) << 8) + indexbytes(buffer, c + 2)
            adapt = (indexbytes(buffer, c + 3) & 0x30) >> 4

            offset = 4
            if adapt & 0x02:
                # meta info present, skip it for now
                adapt_len = indexbytes(buffer, c + offset)
                offset += adapt_len + 1

            if not indexbytes(buffer, c + 1) & 0x40:
                # no new pes or psi in stream payload starting
                pass
            elif adapt & 0x01:
                # PES
                timestamp = self.ReadPESHeader(c + offset, buffer[c + offset:],
                                               tsid)[1]
                if timestamp is not None:
                    if not hasattr(self, 'start'):
                        self.get_time = self.ReadPTS
                        timestamp = c + offset + timestamp
                        self.start = self.get_time(buffer[timestamp:timestamp + 5])
                    elif not hasattr(self, 'audio_ok'):
                        timestamp = c + offset + timestamp
                        start = self.get_time(buffer[timestamp:timestamp + 5])
                        if start is not None and self.start is not None and \
                                abs(start - self.start) < 10:
                            # looks ok
                            self.audio_ok = True
                        else:
                            # timestamp broken
                            del self.start
                            log.warning(u'Timestamp error, correcting')

            if hasattr(self, 'start') and self.start and \
                    self.sequence_header_offset and self.video and self.audio:
                break

            c += TS_PACKET_LENGTH

        if not self.sequence_header_offset:
            return 0

        # fill in values for support functions:
        self.__seek_size__ = 10000000  # 10 MB
        self.__sample_size__ = 100000  # 100 k scanning
        self.__search__ = self._find_timer_TS_
        self.filename = file.name

        # get length of the file
        self.length = self.get_length()
        return 1