def _get_video_list()

in data/video_iterator.py [0:0]


    def _get_video_list(self,
                        video_prefix,
                        txt_list,
                        cache_root=None):
        # formate:
        # [vid, label, video_subpath, num_frames]
        assert os.path.exists(video_prefix), "VideoIter:: failed to locate: `{}'".format(video_prefix)
        assert os.path.exists(txt_list), "VideoIter:: failed to locate: `{}'".format(txt_list)
        if cache_root:
            checked_list = os.path.join(cache_root, os.path.basename(txt_list))
            if os.path.exists(checked_list):
                # load checked_list
                video_list = []
                with open(checked_list) as f:
                    lines = f.read().splitlines()
                    logging.info("VideoIter:: found {} videos in `{}'".format(len(lines), checked_list))
                    for i, line in enumerate(lines):
                        v_id, label, video_subpath = line.split()
                        info = [int(v_id), int(label), video_subpath, -1]
                        video_list.append(info)
                return video_list

        # load list and check if file exists
        video_list = []
        with open(txt_list) as f:
            lines = f.read().splitlines()
            logging.info("VideoIter:: found {} videos in `{}'".format(len(lines), txt_list))
            for i, line in enumerate(lines):
                v_id, label, video_subpath = line.split()
                video_path = os.path.join(video_prefix, video_subpath)
                if not os.path.exists(video_path):
                    # logging.warning("VideoIter:: >> cannot locate `{}'".format(video_path))
                    continue
                info = [int(v_id), int(label), video_subpath, -1]
                video_list.append(info)

        # caching video list
        if cache_root and len(video_list) > 0:
            if not os.path.exists(cache_root):
                os.makedirs(cache_root)
            logging.info("VideoIter:: {} videos are found, caching the valid list to: {}".format(len(video_list), checked_list))
            with open(checked_list, 'w') as f:
                for i, (v_id, label, video_subpath, _) in enumerate(video_list):
                    if i > 0:
                        f.write("\n")
                    f.write("{:d}\t{:d}\t{:s}".format(v_id, label, video_subpath))

        return video_list