コード例 #1
0
ファイル: iso.py プロジェクト: ylatuya/mp4seek
    def read(cls, a):
        # from mp4split
        esdesc = atoms.read_uchar(a.f)
        if esdesc == MP4_ELEMENTARY_STREAM_DESCRIPTOR_TAG:
            len = read_desc_len(a.f)
            stream_id = atoms.read_ushort(a.f)
            prio = atoms.read_uchar(a.f)
        else:
            stream_id = atoms.read_ushort(a.f)

        tag = atoms.read_uchar(a.f)
        len = read_desc_len(a.f)
        if tag != MP4_DECODER_CONFIG_DESCRIPTOR_TAG:
            raise FormatError("can't parse esds")
        object_type_id = atoms.read_uchar(a.f)
        stream_type = atoms.read_uchar(a.f)
        buffer_size_db = a.read_bytes(3)
        maxBitrate = atoms.read_ulong(a.f)
        avgBitrate = atoms.read_ulong(a.f)

        tag = atoms.read_uchar(a.f)
        len = read_desc_len(a.f)
        if tag != MP4_DECODER_SPECIFIC_DESCRIPTOR_TAG:
            raise FormatError("can't parse esd")
        data = a.read_bytes(len)

        return cls(a, object_type_id=object_type_id,
                   maxBitrate=maxBitrate, avgBitrate=avgBitrate, data=data)
コード例 #2
0
ファイル: iso.py プロジェクト: ylatuya/mp4seek
def read_desc_len(f):
    bytes = 0
    len = 0
    while True:
        c = atoms.read_uchar(f)
        len <<= 7
        len |= c & 0x7f
        bytes += 1
        if (bytes == 4):
            break
        if not (c & 0x80):
            break
    return len