class_docstr: This wrapper records videos of rollouts.
  
  Usually, you only want to record episodes intermittently, say every hundredth episode.
  To do this, you can specify **either** ``episode_trigger`` **or** ``step_trigger`` (not both).
  They should be functions returning a boolean that indicates whether a recording should be started at the
  current episode or step, respectively.
  If neither :attr:`episode_trigger` nor ``step_trigger`` is passed, a default ``episode_trigger`` will be employed.
  By default, the recording will be stopped once a `terminated` or `truncated` signal has been emitted by the environment. However, you can
  also create recordings of fixed length (possibly spanning several episodes) by passing a strictly positive value for
  ``video_length``.
class_docstr_tok: ["This","wrapper","records","videos","of","rollouts",".","Usually",",","you","only","want","to","record","episodes","intermittently",",","say","every","hundredth","episode",".","To","do","this",",","you","can","specify","*","*","either","*","*","``","episode_trigger","``","*","*","or","*","*","``","step_trigger","``","(","not","both",")",".","They","should","be","functions","returning","a","boolean","that","indicates","whether","a","recording","should","be","started","at","the","current","episode","or","step",",","respectively",".","If","neither",":","attr",":","`","episode_trigger","`","nor","``","step_trigger","``","is","passed",",","a","default","``","episode_trigger","``","will","be","employed",".","By","default",",","the","recording","will","be","stopped","once","a","`","terminated","`","or","`","truncated","`","signal","has","been","emitted","by","the","environment",".","However",",","you","can","also","create","recordings","of","fixed","length","(","possibly","spanning","several","episodes",")","by","passing","a","strictly","positive","value","for","``","video_length","``","."]
docstr: Wrapper records videos of rollouts.
  
  Args:
      env: The environment that will be wrapped
      video_folder (str): The folder where the recordings will be stored
      episode_trigger: Function that accepts an integer and returns ``True`` iff a recording should be started at this episode
      step_trigger: Function that accepts an integer and returns ``True`` iff a recording should be started at this step
      video_length (int): The length of recorded episodes. If 0, entire episodes are recorded.
          Otherwise, snippets of the specified length are captured
      name_prefix (str): Will be prepended to the filename of the recordings
docstr_tok: ["Wrapper","records","videos","of","rollouts",".","Args",":","env",":","The","environment","that","will","be","wrapped","video_folder","(","str",")",":","The","folder","where","the","recordings","will","be","stored","episode_trigger",":","Function","that","accepts","an","integer","and","returns","``","True","``","iff","a","recording","should","be","started","at","this","episode","step_trigger",":","Function","that","accepts","an","integer","and","returns","``","True","``","iff","a","recording","should","be","started","at","this","step","video_length","(","int",")",":","The","length","of","recorded","episodes",".","If","0",",","entire","episodes","are","recorded",".","Otherwise",",","snippets","of","the","specified","length","are","captured","name_prefix","(","str",")",":","Will","be","prepended","to","the","filename","of","the","recordings"]
code: def __init__(
      self,
      env: gym.Env,
      video_folder: str,
      episode_trigger: Callable[[int], bool] = None,
      step_trigger: Callable[[int], bool] = None,
      video_length: int = 0,
      name_prefix: str = "rl-video",
  ):
      """Wrapper records videos of rollouts.
  
      Args:
          env: The environment that will be wrapped
          video_folder (str): The folder where the recordings will be stored
          episode_trigger: Function that accepts an integer and returns ``True`` iff a recording should be started at this episode
          step_trigger: Function that accepts an integer and returns ``True`` iff a recording should be started at this step
          video_length (int): The length of recorded episodes. If 0, entire episodes are recorded.
              Otherwise, snippets of the specified length are captured
          name_prefix (str): Will be prepended to the filename of the recordings
      """
      super().__init__(env)
  
      if episode_trigger is None and step_trigger is None:
          episode_trigger = capped_cubic_video_schedule
  
      trigger_count = sum(
          x is not None for x in [episode_trigger, step_trigger]
      )
      assert trigger_count == 1, "Must specify exactly one trigger"
  
      self.episode_trigger = episode_trigger
      self.step_trigger = step_trigger
      self.video_recorder: Optional[video_recorder.VideoRecorder] = None
  
      self.video_folder = os.path.abspath(video_folder)
      # Create output folder if needed
      if os.path.isdir(self.video_folder):
          logger.warn(
              f"Overwriting existing videos at {self.video_folder} folder "
              f"(try specifying a different `video_folder` for the `RecordVideo` wrapper if this is not desired)"
          )
      os.makedirs(self.video_folder, exist_ok=True)
  
      self.name_prefix = name_prefix
      self.step_id = 0
      self.video_length = video_length
  
      self.recording = False
      self.terminated = False
      self.truncated = False
      self.recorded_frames = 0
      self.is_vector_env = getattr(env, "is_vector_env", False)
      self.episode_id = 0
  
file_path: gym/gym/wrappers/record_video.py
imports: import os
  from typing import Callable, Optional
  import gym
  from gym import logger
  from gym.wrappers.monitoring import video_recorder
label_desc: Use image node_id 1 to create a new RecordVideo object from inherited base classes: gym with example: obj = RecordVideo(env, video_folder, episode_trigger, step_trigger, video_length, name_prefix)