def extract_pts()

in video.py [0:0]


    def extract_pts(self):
        if self.check_extracted_pts():
            # frames.txt exists and checked OK.
            return

        if not os.path.exists(self.video_file):
            sys.exit("ERROR: input video file '%s' not found.", self.video_file)

        # Get width and height
        tmp_file = tempfile.mktemp(".png")
        cmd = "%s -i %s -vframes 1 %s" % (ffmpeg, self.video_file, tmp_file)
        print(cmd)
        res = os.popen(cmd).read()
        image = image_io.load_image(tmp_file)
        height = image.shape[0]
        width = image.shape[1]
        os.remove(tmp_file)
        if os.path.exists(tmp_file):
            sys.exit("ERROR: unable to remove '%s'" % tmp_file)

        # Get PTS
        def parse_line(line, token):
            if line[: len(token)] != token:
                sys.exit("ERROR: record is malformed, expected to find '%s'." % token)
            return line[len(token) :]

        ffprobe_cmd = "%s %s -select_streams v:0 -show_frames" % (
            ffprobe,
            self.video_file,
        )
        cmd = ffprobe_cmd + " | grep pkt_pts_time"
        print(cmd)
        res = os.popen(cmd).read()
        pts = []
        for line in res.splitlines():
            pts.append(parse_line(line, "pkt_pts_time="))
        self.frame_count = len(pts)
        print("%d frames detected." % self.frame_count)

        pts_file = "%s/frames.txt" % self.path
        with open(pts_file, "w") as file:
            file.write("%d\n" % len(pts))
            file.write("%s\n" % width)
            file.write("%s\n" % height)
            for t in pts:
                file.write("%s\n" % t)

        self.check_extracted_pts()