def process_frame(frame): """Process a frame, holding onto one P-frame at a time, which is used to replace any I-frames encountered.""" if buf[0] == None or not is_iframe(frame): buf[0] = frame else: frame = buf[0] return frame
def magnify_iter(stream): all_frames = iter(stream) yield next(all_frames) while True: frame = next(all_frames) if not is_iframe(frame): yield frame yield frame
def echo_stream(stream, midpoint=0.5): all_frames = list(stream) pframes = [f for f in all_frames if not is_iframe(f)] midpoint_idx = int(len(all_frames) * midpoint) frames = all_frames[:midpoint_idx] while len(frames) < len(all_frames): frames += pframes[:(len(all_frames) - len(frames))] return frames
def process_frame(frame, buf): '''Determines if given frame is a p-frame or an i-frame. If it is an i-frame, the buffer stays the same and it returns the frame held in the buffer. If it is a p-frame, it replaces the buffer with the frame, and returns the frame.''' #if there is no frame in buf or the frame is not i-frame if buf[0] == None or not is_iframe(frame): #then buf is the seen p-frame buf[0] = frame else: #if it IS an iframe then use the buf'ers pframe frame = buf[0] #return the frame return frame
def drift_stream(stream, midpoint=0.5): repeated_frame = None for idx, frame in enumerate(stream): if idx < len(stream) * midpoint: yield frame elif is_iframe(frame): pass else: if repeated_frame is None: repeated_frame = frame yield repeated_frame
def process_frame(frame): """Process a frame, holding onto one P-frame at a time, which is used to replace any I-frames encountered.""" #if there is no frame in buf or the frame is not i-frame if buf[0] == None or not is_iframe(frame): #then buf is the seen p-frame buf[0] = frame else: #if it IS an iframe then use the buf'ers pframe frame = buf[0] #return the frame return frame