  import os
  from pathlib import Path
  
  import cv2
  import imageio_ffmpeg as im_ffm
  import numpy as np
  
  from lib.aligner import Extract as AlignerExtract
  from lib.alignments import Alignments as AlignmentsBase
  from lib.face_filter import FaceFilter as FilterFunc
 
</s> remove         cap = cv2.VideoCapture(self.args.input_dir)  # pylint: disable=no-member
        cap.set(cv2.CAP_PROP_POS_FRAMES, frame_no - 1)  # pylint: disable=no-member
        ret, frame = cap.read()
        if not ret:
            logger.error("Unable to read from %s from video %s", frame_no, self.args.input_dir)
            exit(1)
        cap.release()
 </s> add         reader = imageio.get_reader(self.args.input_dir)
        reader.set_image_index(frame_no - 1)
        frame = reader.get_next_data()[:, :, ::-1]
        reader.close() </s> remove         cap = cv2.VideoCapture(self.args.input_dir)  # pylint: disable=no-member
        i = 0
        while True:
            ret, frame = cap.read()
            if not ret:
                logger.debug("Video terminated")
                break
            i += 1
            # Keep filename format for outputted face
            filename = "{}_{:06d}.png".format(vidname, i)
 </s> add         reader = imageio.get_reader(self.args.input_dir)
        for i, frame in enumerate(reader):
            # Convert to BGR for cv2 compatibility
            frame = frame[:, :, ::-1]
            filename = "{}_{:06d}.png".format(vidname, i + 1) </s> remove         self.vid_cap.set(cv2.CAP_PROP_POS_FRAMES, frame_no)  # pylint: disable=no-member
        _, image = self.vid_cap.read()
 </s> add         self.vid_reader.set_image_index(frame_no)
        image = self.vid_reader.get_next_data()[:, :, ::-1] </s> remove         iterator = self.process_video if self.vid_cap else self.process_frames
 </s> add         iterator = self.process_video if self.vid_reader is not None else self.process_frames
import imageio
  import os
  from pathlib import Path
  
  import cv2
import imageio
  import imageio_ffmpeg as im_ffm
  import numpy as np
  
  from lib.aligner import Extract as AlignerExtract
  from lib.alignments import Alignments as AlignmentsBase
  from lib.face_filter import FaceFilter as FilterFunc
keep keep keep add keep keep keep keep keep keep
 Replace CV2 video loading with ImageIO 
scripts/fsmedia.py