code: def __init_ffmpeg(self, image_shape):
      
      import itertools  # pylint: disable=g-import-not-at-top
      from subprocess import Popen, PIPE  # pylint: disable=g-import-not-at-top,g-multiple-import,g-importing-member
      ffmpeg = "ffmpeg"
      height, width, channels = image_shape
      self.cmd = [
          ffmpeg, "-y",
          "-f", "rawvideo",
          "-vcodec", "rawvideo",
          "-r", "%.02f" % self.fps,
          "-s", "%dx%d" % (width, height),
          "-pix_fmt", {1: "gray", 3: "rgb24"}[channels],
          "-i", "-",
          "-filter_complex", "[0:v]split[x][z];[x]fifo[w];[z]palettegen,fifo[y];"
                             "[w][y]paletteuse,fifo",
          "-r", "%.02f" % self.fps,
          "-f", self.file_format,
          "-qscale", "0",
          "-"
      ]
      self.proc = Popen(
          self.cmd, stdin=PIPE, stdout=PIPE, stderr=PIPE, bufsize=-1
      )
      (self._out_thread, self._err_thread) = itertools.starmap(
          self._start_reader_thread, [
              (self.proc.stdout, self._out_chunks),
              (self.proc.stderr, self._err_chunks)
          ]
      )
docs: Initializes ffmpeg to write frames.