(directory, orange_file)
Remove stray frames from the start of the video
Remove stray frames from the start of the video
Remove stray frames from the start of the video
def remove_frames_before_orange(directory, orange_file):
    """Remove stray frames from the start of the video"""
    frames = sorted(glob.glob(os.path.join(directory, 'video-*.png')))
    if len(frames):
        # go through the first 20 frames and remove any that come before the first orange frame.
        # iOS video capture starts with a blank white frame and then flips to
        # orange before starting.
        logging.debug("Scanning for non-orange frames...")
        found_orange = False
        remove_frames = []
        frame_count = 0
        for frame in frames:
            frame_count += 1
            if is_color_frame(frame, orange_file):
                found_orange = True
                break
            if frame_count > 20:
                break
            remove_frames.append(frame)

        if found_orange and len(remove_frames):
            for frame in remove_frames:
                logging.debug("Removing pre-orange frame %s", frame)
                os.remove(frame)
def remove_frames_before_orange ( directory , orange_file ) : frames = sorted ( glob . glob ( os . path . join ( directory , 'video-*.png' ) ) ) if len ( frames ) : # go through the first 20 frames and remove any that come before the first orange frame. # iOS video capture starts with a blank white frame and then flips to # orange before starting. logging . debug ( "Scanning for non-orange frames..." ) found_orange = False remove_frames = [ ] frame_count = 0 for frame in frames : frame_count += 1 if is_color_frame ( frame , orange_file ) : found_orange = True break if frame_count > 20 : break remove_frames . append ( frame ) if found_orange and len ( remove_frames ) : for frame in remove_frames : logging . debug ( "Removing pre-orange frame %s" , frame ) os . remove ( frame )