class_docstr: Class that provides a simple and pythonic way to interact with video.
  
  It returns regular OpenCV frames which enables the usage of the huge number of tools OpenCV provides to modify images.
  
  Parameters
  ----------
  camera : Optional[int], optional
      An integer representing the device id of the camera to be used as the video source.
  
      Webcams tend to have an id of `0`. Arguments `camera` and `input_path` can't be used at the same time, one must be chosen.
  input_path : Optional[str], optional
      A string consisting of the path to the video file to be used as the video source.
  
      Arguments `camera` and `input_path` can't be used at the same time, one must be chosen.
  output_path : str, optional
      The path to the output video to be generated.
      Can be a folder were the file will be created or a full path with a file name.
  output_fps : Optional[float], optional
      The frames per second at which to encode the output video file.
  
      If not provided it is set to be equal to the input video source's fps.
      This argument is useful when using live video cameras as a video source,
      where the user may know the input fps,
      but where the frames are being fed to the output video at a rate that is lower than the video source's fps,
      due to the latency added by the detector.
  label : str, optional
      Label to add to the progress bar that appears when processing the current video.
  output_fourcc : Optional[str], optional
      OpenCV encoding for output video file.
      By default we use `mp4v` for `.mp4` and `XVID` for `.avi`. This is a combination that works on most systems but
      it results in larger files. To get smaller files use `avc1` or `H264` if available.
      Notice that some fourcc are not compatible with some extensions.
  output_extension : str, optional
      File extension used for the output video. Ignored if `output_path` is not a folder.
  
  Examples
  --------
  >>> video = Video(input_path="video.mp4")
  >>> for frame in video:
  >>>     # << Your modifications to the frame would go here >>
  >>>     video.write(frame)
code: def __init__(
      self,
      camera: Optional[int] = None,
      input_path: Optional[str] = None,
      output_path: str = ".",
      output_fps: Optional[float] = None,
      label: str = "",
      output_fourcc: Optional[str] = None,
      output_extension: str = "mp4",
  ):
      self.camera = camera
      self.input_path = input_path
      self.output_path = output_path
      self.label = label
      self.output_fourcc = output_fourcc
      self.output_extension = output_extension
      self.output_video: Optional[cv2.VideoWriter] = None
  
      # Input validation
      if (input_path is None and camera is None) or (
          input_path is not None and camera is not None
      ):
          raise ValueError(
              "You must set either 'camera' or 'input_path' arguments when setting 'Video' class"
          )
      if camera is not None and type(camera) is not int:
          raise ValueError(
              "Argument 'camera' refers to the device-id of your camera, and must be an int. Setting it to 0 usually works if you don't know the id."
          )
  
      # Read Input Video
      if self.input_path is not None:
          if "~" in self.input_path:
              self.input_path = os.path.expanduser(self.input_path)
          if not os.path.isfile(self.input_path):
              self._fail(
                  f"[bold red]Error:[/bold red] File '{self.input_path}' does not exist."
              )
          self.video_capture = cv2.VideoCapture(self.input_path)
          total_frames = int(
              self.video_capture.get(cv2.CAP_PROP_FRAME_COUNT)
          )
          if total_frames == 0:
              self._fail(
                  f"[bold red]Error:[/bold red] '{self.input_path}' does not seem to be a video file supported by OpenCV. If the video file is not the problem, please check that your OpenCV installation is working correctly."
              )
          description = os.path.basename(self.input_path)
      else:
          self.video_capture = cv2.VideoCapture(self.camera)
          total_frames = 0
          description = f"Camera({self.camera})"
      self.output_fps = (
          output_fps
          if output_fps is not None
          else self.video_capture.get(cv2.CAP_PROP_FPS)
      )
      self.input_height = self.video_capture.get(
          cv2.CAP_PROP_FRAME_HEIGHT
      )
      self.input_width = self.video_capture.get(
          cv2.CAP_PROP_FRAME_WIDTH
      )
      self.frame_counter = 0
  
      # Setup progressbar
      if self.label:
          description += f" | {self.label}"
      progress_bar_fields: List[Union[str, ProgressColumn]] = [
          "[progress.description]{task.description}",
          BarColumn(),
          "[yellow]{task.fields[process_fps]:.2f}fps[/yellow]",
      ]
      if self.input_path is not None:
          progress_bar_fields.insert(
              2, "[progress.percentage]{task.percentage:>3.0f}%"
          )
          progress_bar_fields.insert(
              3,
              TimeRemainingColumn(),
          )
      self.progress_bar = Progress(
          *progress_bar_fields,
          auto_refresh=False,
          redirect_stdout=False,
          redirect_stderr=False,
      )
      self.task = self.progress_bar.add_task(
          self.abbreviate_description(description),
          total=total_frames,
          start=self.input_path is not None,
          process_fps=0,
      )
  
imports: import os
  import time
  from typing import List, Optional, Union
  import numpy
  from rich import print
  from rich.progress import BarColumn, Progress, ProgressColumn, TimeRemainingColumn
  from norfair import metrics
  from .utils import get_terminal_size
label_desc: Use image node_id 1 to create a new Video object  with example: obj = Video(camera, input_path, output_path, output_fps, label, output_fourcc, output_extension)