class_docstr: Wrapper which creates and records videos from generated observations.
  
  This will limit itself to recording once every `record_every` episodes and
  videos will be recorded to the directory `path` + '/<unique id>/videos' where
  `path` defaults to '~/acme'. Users can specify the size of the screen by
  passing either a tuple giving height and width or a float giving the size
  of the diagonal.
docstr: Writes frames to video.
docstr_tok: ["Writes","frames","to","video","."]
code: def _write_frames(self):
      """Writes frames to video."""
      if self._counter % self._record_every == 0:
          animation = make_animation(
              self._frames, self._frame_rate, self._figsize
          )
          path_without_extension = os.path.join(
              self._path, f"{self._filename}_{self._counter:04d}"
          )
          if self._to_html:
              path = path_without_extension + ".html"
              video = animation.to_html5_video()
              with open(path, "w") as f:
                  f.write(video)
          else:
              path = path_without_extension + ".m4v"
              # Animation.save can save only locally. Save first and copy using
              # gfile.
              with tempfile.TemporaryDirectory() as tmp_dir:
                  tmp_path = os.path.join(tmp_dir, "temp.m4v")
                  animation.save(tmp_path)
                  with open(path, "wb") as f:
                      with open(tmp_path, "rb") as g:
                          f.write(g.read())
  
      # Clear the frame buffer whether a video was generated or not.
      self._frames = []
  
imports: import os.path
  import tempfile
  from typing import Callable, Optional, Sequence, Tuple, Union
  from acme.utils import paths
  from acme.wrappers import base
  import dm_env
  import matplotlib
  import matplotlib.animation
  import matplotlib.pyplot
  import numpy
label_desc: Use image node_id 3 for calling the VideoWrapper obj's underlying member method code with example usage: obj._write_frames() without return types