def _initialize(self):
        container = av.open(self.filename)
 
        # Build a toc 
        self._toc = np.cumsum([len(packet.decode())
                               for packet in container.demux()])
        self._len = self._toc[-1]

        video_stream = [s for s in container.streams
                        if isinstance(s, av.video.VideoStream)][0]
        # PyAV always returns frames in color, and we make that
        # assumption in get_frame() later below, so 3 is hardcoded here:
        self._im_sz = video_stream.width, video_stream.height, 3

        del container  # The generator is empty. Reload the file.
        self._load_fresh_file()
Scan through and tabulate contents to enable random access.
dataset/ETHPy150Open soft-matter/pims/pims/pyav_reader.py/PyAVVideoReader._initialize