code: def preprocess(from_idx, to_idx, _params):
      
      source_exts = '*.mpg'
      src_path = _params['src_path']
      tgt_path = _params['tgt_path']
      face_predictor_path = './shape_predictor_68_face_landmarks.dat'
  
      succ = set()
      fail = set()
      for idx in range(from_idx, to_idx):
          s_id = 's' + str(idx) + '/'
          source_path = src_path + '/' + s_id
          target_path = tgt_path + '/' + s_id
          fail_cnt = 0
          for filepath in find_files(source_path, source_exts):
              print("Processing: {}".format(filepath))
              filepath_wo_ext = os.path.splitext(filepath)[0].split('/')[-2:]
              target_dir = os.path.join(tgt_path, '/'.join(filepath_wo_ext))
  
              if os.path.exists(target_dir):
                  continue
  
              try:
                  video = Video(vtype='face', \
                                  face_predictor_path=face_predictor_path).from_video(filepath)
                  mkdir_p(target_dir)
                  i = 0
                  if video.mouth[0] is None:
                      continue
                  for frame in video.mouth:
                      io.imsave(os.path.join(target_dir, "mouth_{0:03d}.png".format(i)), frame)
                      i += 1
              except ValueError as error:
                  print(error)
                  fail_cnt += 1
          if fail_cnt == 0:
              succ.add(idx)
          else:
              fail.add(idx)
      return (succ, fail)
docs: Preprocess: Convert a video into the mouth images