def read(cls, a): a.seek_to_data() bufferSize = atoms.read_ulong(a.f) maxBitrate = atoms.read_ulong(a.f) avgBitrate = atoms.read_ulong(a.f) return cls(a, bufferSize=bufferSize, maxBitrate=maxBitrate, avgBitrate=avgBitrate)
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)
def read(cls, a): ss = read_ulong(a.f) entries = read_ulong(a.f) if ss == 0: t = read_table(a.f, 'L', entries) else: t = [] return cls(a, sample_size=ss, table=t)
def read(cls, a): count = read_ulong(a.f) entries = [] while count > 0: b = atoms.read_atom(a.f) entries.append(b) count = count - 1 entries = map(lambda a: maybe_build_atoms(a.type, [a])[0], entries) return cls(a, count=count, entries=entries)
def read(cls, a): field_size = read_ulong(a.f) & 0xff entries = read_ulong(a.f) def read_2u4(f): b = read_bytes(f, 1) return (b >> 4) & 0x0f, b & 0x0f def flatten(l): ret = [] for elt in l: ret.extend(elt) return ret if field_size == 16: t = read_table(a.f, 'H', entries) elif field_size == 8: t = read_table(a.f, 'B', entries) elif field_size == 4: t = flatten([read_2u4(a.f) for _ in xrange((entries + 1) / 2)]) else: raise FormatError() return cls(a, field_size=field_size, table=t)
def read(cls, a): a.seek_to_data() a.skip(6) idx = atoms.read_ushort(a.f) a.skip(4 * 4) width = atoms.read_ushort(a.f) height = atoms.read_ushort(a.f) hr = a.read_bytes(4) vr = a.read_bytes(4) reserved = atoms.read_ulong(a.f) fc = atoms.read_ushort(a.f) comp = a.read_bytes(32) depth = atoms.read_ushort(a.f) minusone = atoms.read_short(a.f) if (minusone != -1): raise FormatError() # optional boxes follow extra = list(atoms.read_atoms(a.f, a.size - 86)) a.seek_to_data() a.skip(86) extra = map(lambda a: maybe_build_atoms(a.type, [a])[0], extra) return cls(a, index=idx, width=width, height=height, comp=comp, extra=extra)
def read(cls, a): track_id = read_ulong(a.f) return cls(a, track_id=track_id)
def read(cls, a): a.seek_to_data() brand = read_fcc(a.f) v = read_ulong(a.f) return cls(a, brand=brand, version=v)
def read(cls, a): entries = read_ulong(a.f) t = read_table(a.f, 'Q', entries) return cls(a, table=t)
def read(cls, a): ver_skip(a, (8, 16)) ts = read_ulong(a.f) d = ver_read(a, (read_ulong, read_ulonglong)) return cls(a, timescale=ts, duration=d)
def read(cls, a): ver_skip(a, (8, 16)) id = read_ulong(a.f) a.skip(4) d = ver_read(a, (read_ulong, read_ulonglong)) return cls(a, duration=d, id=id)