def parse_stco(reader, size): version = reader.read32() box = ChunkOffsetBox(size, version, 0) box.entry_count = reader.read32() for _ in range(0, box.entry_count): box.chunk_offset.append(reader.read32()) return box
def test_sync_sample(self): stbl = SampleTableBox(0,0,0) stbl.stsc = SampleToChunkBox(0,0,0) stbl.stco = ChunkOffsetBox(0,0,0) stbl.stco.entry_count = 4 stbl.stsc.entry_count = 3 stbl.stsc.first_chunk = [1, 2, 58] stbl.stsc.samples_per_chunk = [13, 12, 3] stbl.stss = SyncSampleBox(0, 0, 0) stbl.stss.entry_count = 4 stbl.stss.sample_number = [1, 49, 97]
def test_sample_count_generation_4(self): stbl = SampleTableBox(0,0,0) stbl.stsc = SampleToChunkBox(0,0,0) stbl.stco = ChunkOffsetBox(0,0,0) stbl.stco.entry_count = 1 stbl.stsc.entry_count = 1 stbl.stsc.first_chunk = [1] stbl.stsc.samples_per_chunk = [1] fg = SampleGenerator(stbl) g = fg.get_sample_count() self.assertEqual(next(g), 1) self.assertRaises(StopIteration, next, g)
def test_video_sample_generation(self): stbl = SampleTableBox(0,0,0) stbl.stsc = SampleToChunkBox(0,0,0) stbl.stco = ChunkOffsetBox(0,0,0) stbl.stco.entry_count = 1 stbl.stsc.entry_count = 1 stbl.stsc.first_chunk = [1] stbl.stsc.samples_per_chunk = [1] with open("output_squirrel.mp4") as f: reader = StreamReader(f) parse_trak(reader, size) fg = VideoSampleGenerator(reader, stbl)
def test_sample_count_generation_2(self): stbl = SampleTableBox(0,0,0) stbl.stsc = SampleToChunkBox(0,0,0) stbl.stco = ChunkOffsetBox(0,0,0) stbl.stco.entry_count = 3 stbl.stsc.entry_count = 3 stbl.stsc.first_chunk = [1,2,3] stbl.stsc.samples_per_chunk = [6,7,8] fg = SampleGenerator(stbl) g = fg.get_sample_count() self.assertEqual(next(g), 6) self.assertEqual(next(g), 7) self.assertEqual(next(g), 8)