def cvt2frames(self,<EOL>frame_dir,<EOL>file_start=<NUM_LIT:0>,<EOL>filename_tmpl='<STR_LIT>',<EOL>start=<NUM_LIT:0>,<EOL>max_num=<NUM_LIT:0>,<EOL>show_progress=True):
mkdir_or_exist(frame_dir)<EOL>if max_num == <NUM_LIT:0>:<EOL><INDENT>task_num = self.frame_cnt - start<EOL><DEDENT>else:<EOL><INDENT>task_num = min(self.frame_cnt - start, max_num)<EOL><DEDENT>if task_num <= <NUM_LIT:0>:<EOL><INDENT>raise ValueError('<STR_LIT>')<EOL><DEDENT>if start > <NUM_LIT:0>:<EOL><INDENT>self._set_real_position(start)<EOL><DEDENT>def write_frame(file_idx):<EOL><INDENT>img = self.read()<EOL>filename = osp.join(frame_dir, filename_tmpl.format(file_idx))<EOL>cv2.imwrite(filename, img)<EOL><DEDENT>if show_progress:<EOL><INDENT>track_progress(write_frame, range(file_start,<EOL>file_start + task_num))<EOL><DEDENT>else:<EOL><INDENT>for i in range(task_num):<EOL><INDENT>img = self.read()<EOL>if img is None:<EOL><INDENT>break<EOL><DEDENT>filename = osp.join(frame_dir,<EOL>filename_tmpl.format(i + file_start))<EOL>cv2.imwrite(filename, img)<EOL><DEDENT><DEDENT>
Convert a video to frame images

        Args:
            frame_dir (str): Output directory to store all the frame images.
            file_start (int): Filenames will start from the specified number.
            filename_tmpl (str): Filename template with the index as the
                placeholder.
            start (int): The starting frame index.
            max_num (int): Maximum number of frames to be written.
            show_progress (bool): Whether to show a progress bar.