#NEWLINE# def _initialize( self ) : #NEWLINE# #INDENT# 'Scan through and tabulate contents to enable random access.' #NEWLINE# container = av . open ( self . filename ) #NEWLINE# self . _toc = np . cumsum ( [ len ( packet . decode ( ) ) for packet in container . demux ( ) ] ) #NEWLINE# self . _len = self . _toc [ ( - 1 ) ] #NEWLINE# video_stream = [ s for s in container . streams if isinstance ( s , av . video . VideoStream ) ] [ 0 ] #NEWLINE# self . _im_sz = ( video_stream . width , s . height , 3 ) #NEWLINE# del container #NEWLINE# self . _load_fresh_file ( )