def get_frames_iter():
    """
    This function returns a iterator of frames of test videos.
    Each iteration provides a tuple of (video_id, frames), each frame will be in RGB color format with array shape of (height, width, 3).
    return: tuple(video_id: str, frames: list)
    """
    video_list = _get_s3_video_list(WORKSPACE_BUCKET, VIDEO_LIST_PATH)
    logging.info("got video list, {} videos".format(len(video_list)))

    for video_id in video_list:
        # get video from s3
        st = time.time()
        try:
            _download_s3_video(WORKSPACE_BUCKET, os.path.join(VIDEO_PREFIX, video_id), video_id)
        except:
            logging.info("Failed to download video: {}".format(os.path.join(VIDEO_PREFIX, video_id)))
            raise
        video_local_path = os.path.join(TMP_PATH, video_id) # local path of the video named video_id
        frames = extract_frames(video_local_path)
        elapsed = time.time() - st
        logging.info("video downloading & frames extracting time: {}".format(elapsed))
        yield video_id, frames
        try:
            os.remove(video_local_path) # remove the video named video_id
        except:
            logging.info("Failed to delete this video, error: {}".format(sys.exc_info()[0]))
def get_local_frames_iter(max_number=None):
    """
    This function returns a iterator of frames of test videos.
    It is used for local test of participating algorithms.
    Each iteration provides a tuple of (video_id, frames), each frame will be in RGB color format with array shape of (height, width, 3)
    return: tuple(video_id: str, frames: list)
    """
    video_list = [x.strip() for x in open(VIDEO_LIST_PATH)]
    logging.info("got local video list, {} videos".format(len(video_list)))

    for video_id in video_list:
        # get video from local file
        try:
            frames = extract_frames(os.path.join(VIDEO_PREFIX, video_id))
        except:
            logging.info("Failed to read image: {}".format(os.path.join(VIDEO_PREFIX, video_id)))
            raise
        yield video_id, frames