def read_iso_file(fobj): fobj.seek(0) al = list(atoms.read_atoms(fobj)) ad = atoms.atoms_dict(al) aftyp, amoov, mdat = select_atoms(ad, ('ftyp', 1, 1), ('moov', 1, 1), ('mdat', 1, None)) # print '(first mdat offset: %d)' % mdat[0].offset return aftyp, amoov, al
def load(args): if not os.path.isfile(args): print("File %s not found" % args) return 1 else: print("Loading file %s" % args) f = open(args, "rb") global_dat.globdat = f.read() f.close() print("Length of data: %d" % len(global_dat.globdat)) a.read_atoms(global_dat.globdat) for atom in global_dat.atoms: print() atom.printMe() # if atom.name == "mdat": # print("\t**s an mdat atom. Has no children :)") #else: a.find_childs(atom) print("Load Complete")
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): a.seek_to_data() a.skip(6) # reserved idx = atoms.read_ushort(a.f) version = atoms.read_ushort(a.f) a.skip(4 + 2) # reserved channelcount = atoms.read_ushort(a.f) if channelcount == 3: channelcount = 6 # from mp4split samplesize = atoms.read_ushort(a.f) a.skip(4) sampleratehi = atoms.read_ushort(a.f) sampleratelo = atoms.read_ushort(a.f) # FIXME: parse version != 0 samples_per_packet etc.. # optional boxes follow extra = list(atoms.read_atoms(a.f, a.size - 36)) a.seek_to_data() a.skip(36) extra = map(lambda a: maybe_build_atoms(a.type, [a])[0], extra) return cls(a, index=idx, channelcount=channelcount, samplesize=samplesize, sampleratehi=sampleratehi, sampleratelo=sampleratelo, extra=extra)