#NEWLINE# def generate_frames( s , index = 0 ) : #NEWLINE# #INDENT# pos = 0 #NEWLINE# timestamp = 0 #NEWLINE# for data in s : #NEWLINE# #INDENT# if ( data == 'k' ) : #NEWLINE# #INDENT# pos += 1 #NEWLINE# ( yield ( data , PiVideoFrame ( index = index , frame_type = PiVideoFrameType . key_frame , frame_size = 1 , video_size = pos , split_size = pos , timestamp = timestamp , complete = False ) ) ) #NEWLINE# #UNINDENT# pos += 1 #NEWLINE# ( yield ( data , PiVideoFrame ( index = index , frame_type = { #NEWLINE# #INDENT# 'f' : PiVideoFrameType . frame , #NEWLINE# 'k' : PiVideoFrameType . key_frame , #NEWLINE# 'h' : PiVideoFrameType . sps_header , #NEWLINE# 'm' : PiVideoFrameType . motion_data , #NEWLINE# #UNINDENT# } [ data ] , frame_size = { #NEWLINE# #INDENT# 'f' : 1 , #NEWLINE# 'k' : 2 , #NEWLINE# 'h' : 1 , #NEWLINE# 'm' : 1 , #NEWLINE# #UNINDENT# } [ data ] , video_size = pos , split_size = pos , timestamp = timestamp , complete = True ) ) ) #NEWLINE# index += 1 #NEWLINE# timestamp += 1000000