Ejemplo n.º 1
0
 def test_mdhd_version_1(self, soun=b"soun"):
     mdhd = Atom.render(b"mdhd", (b"\x01\x00\x00\x00" + b"\x00" * 16 +
                                  b"\x00\x00\x00\x02" +  # 2 Hz
                                  b"\x00\x00\x00\x00\x00\x00\x00\x10"))
     hdlr = Atom.render(b"hdlr", b"\x00" * 8 + soun)
     mdia = Atom.render(b"mdia", mdhd + hdlr)
     trak = Atom.render(b"trak", mdia)
     moov = Atom.render(b"moov", trak)
     fileobj = cBytesIO(moov)
     atoms = Atoms(fileobj)
     info = MP4Info(atoms, fileobj)
     self.failUnlessEqual(info.length, 8)
Ejemplo n.º 2
0
 def load(self, fp):
     self.filename = fp.name
     fileobj = fp
     try:
         atoms = Atoms(fileobj)
         try: self.info = MP4Info(atoms, fileobj)
         except StandardError, err:
             raise MP4StreamInfoError, err, sys.exc_info()[2]
         try: self.tags = MP4Tags(atoms, fileobj)
         except MP4MetadataError:
             self.tags = None
         except StandardError, err:
             raise MP4MetadataError, err, sys.exc_info()[2]
Ejemplo n.º 3
0
 def test_multiple_tracks(self):
     hdlr = Atom.render(b"hdlr", b"\x00" * 8 + b"whee")
     mdia = Atom.render(b"mdia", hdlr)
     trak1 = Atom.render(b"trak", mdia)
     mdhd = Atom.render(b"mdhd", (b"\x01\x00\x00\x00" + b"\x00" * 16 +
                                  b"\x00\x00\x00\x02" +  # 2 Hz
                                  b"\x00\x00\x00\x00\x00\x00\x00\x10"))
     hdlr = Atom.render(b"hdlr", b"\x00" * 8 + b"soun")
     mdia = Atom.render(b"mdia", mdhd + hdlr)
     trak2 = Atom.render(b"trak", mdia)
     moov = Atom.render(b"moov", trak1 + trak2)
     fileobj = cBytesIO(moov)
     atoms = Atoms(fileobj)
     info = MP4Info(atoms, fileobj)
     self.failUnlessEqual(info.length, 8)
Ejemplo n.º 4
0
 def test_no_tracks(self):
     moov = Atom.render(b"moov", b"")
     fileobj = BytesIO(moov)
     atoms = Atoms(fileobj)
     with self.assertRaises(MP4StreamInfoError):
         MP4Info(atoms, fileobj)