class_docstr: Encode and write audio/video streams chunk by chunk
  
  Args:
      dst (str, path-like or file-like object): The destination where the encoded data are written.
          If string-type, it must be a resource indicator that FFmpeg can
          handle. The supported value depends on the FFmpeg found in the system.
  
          If file-like object, it must support `write` method with the signature
          `write(data: bytes) -> int`.
  
          Please refer to the following for the expected signature and behavior of
          `write` method.
  
          - https://docs.python.org/3/library/io.html#io.BufferedIOBase.write
  
      format (str or None, optional):
          Override the output format, or specify the output media device.
          Default: ``None`` (no override nor device output).
  
          This argument serves two different use cases.
  
          1) Override the output format.
             This is useful when writing raw data or in a format different from the extension.
  
          2) Specify the output device.
             This allows to output media streams to hardware devices,
             such as speaker and video screen.
  
          .. note::
  
             This option roughly corresponds to ``-f`` option of ``ffmpeg`` command.
             Please refer to the ffmpeg documentations for possible values.
  
             https://ffmpeg.org/ffmpeg-formats.html#Muxers
  
             Please use :py:func:`~torio.utils.ffmpeg_utils.get_muxers` to list the
             multiplexers available in the current environment.
  
             For device access, the available values vary based on hardware (AV device) and
             software configuration (ffmpeg build).
             Please refer to the ffmpeg documentations for possible values.
  
             https://ffmpeg.org/ffmpeg-devices.html#Output-Devices
  
             Please use :py:func:`~torio.utils.ffmpeg_utils.get_output_devices` to list
             the output devices available in the current environment.
  
      buffer_size (int):
          The internal buffer size in byte. Used only when `dst` is a file-like object.
  
          Default: `4096`.
class_docstr_tok: ["Encode","and","write","audio\/video","streams","chunk","by","chunk","Args",":","dst","(","str",",","path-like","or","file-like","object",")",":","The","destination","where","the","encoded","data","are","written",".","If","string-type",",","it","must","be","a","resource","indicator","that","FFmpeg","can","handle",".","The","supported","value","depends","on","the","FFmpeg","found","in","the","system",".","If","file-like","object",",","it","must","support","`","write","`","method","with","the","signature","`","write","(","data",":","bytes",")","-",">","int","`",".","Please","refer","to","the","following","for","the","expected","signature","and","behavior","of","`","write","`","method",".","-","https",":","\/\/docs.python.org\/3\/library\/io.html","#","io.BufferedIOBase.write","format","(","str","or","None",",","optional",")",":","Override","the","output","format",",","or","specify","the","output","media","device",".","Default",":","``","None","``","(","no","override","nor","device","output",")",".","This","argument","serves","two","different","use","cases",".","1",")","Override","the","output","format",".","This","is","useful","when","writing","raw","data","or","in","a","format","different","from","the","extension",".","2",")","Specify","the","output","device",".","This","allows","to","output","media","streams","to","hardware","devices",",","such","as","speaker","and","video","screen",".","..","note",":",":","This","option","roughly","corresponds","to","``","-f","``","option","of","``","ffmpeg","``","command",".","Please","refer","to","the","ffmpeg","documentations","for","possible","values",".","https",":","\/\/ffmpeg.org\/ffmpeg-formats.html","#","Muxers","Please","use",":","py",":","func",":","`","~torio.utils.ffmpeg_utils.get_muxers","`","to","list","the","multiplexers","available","in","the","current","environment",".","For","device","access",",","the","available","values","vary","based","on","hardware","(","AV","device",")","and","software","configuration","(","ffmpeg","build",")",".","Please","refer","to","the","ffmpeg","documentations","for","possible","values",".","https",":","\/\/ffmpeg.org\/ffmpeg-devices.html","#","Output-Devices","Please","use",":","py",":","func",":","`","~torio.utils.ffmpeg_utils.get_output_devices","`","to","list","the","output","devices","available","in","the","current","environment",".","buffer_size","(","int",")",":","The","internal","buffer","size","in","byte",".","Used","only","when","`","dst","`","is","a","file-like","object",".","Default",":","`","4096","`","."]
docstr: Add an output video stream.
  
  This method has to be called before `open` is called.
  
  Args:
      frame_rate (float): Frame rate of the video.
  
      width (int): Width of the video frame.
  
      height (int): Height of the video frame.
  
      format (str, optional): Input pixel format, which determines the
          color channel order of the input tensor.
  
          - ``"gray8"``: One channel, grayscale.
          - ``"rgb24"``: Three channels in the order of RGB.
          - ``"bgr24"``: Three channels in the order of BGR.
          - ``"yuv444p"``: Three channels in the order of YUV.
  
          Default: ``"rgb24"``.
  
          In either case, the input tensor has to be ``torch.uint8`` type and
          the shape must be (frame, channel, height, width).
  
      encoder (str or None, optional): {encoder}
  
      encoder_option (dict or None, optional): {encoder_option}
  
      encoder_frame_rate (float or None, optional): Override the frame rate used for encoding.
  
          Some encoders, (such as ``"mpeg1"`` and ``"mpeg2"``) pose restriction on the
          frame rate that can be used for encoding.
          If such case, if the source frame rate (provided as ``frame_rate``) is not
          one of the supported frame rate, then a default one is picked, and the frame rate
          is changed on-the-fly. Otherwise the source frame rate is used.
  
          Providing ``encoder_frame_rate`` will override this behavior and
          make encoder attempts to use the provided sample rate.
          The provided value must be one support by the encoder.
  
      encoder_width (int or None, optional): Width of the image used for encoding.
          This allows to change the image size during encoding.
  
      encoder_height (int or None, optional): Height of the image used for encoding.
          This allows to change the image size during encoding.
  
      encoder_format (str or None, optional): {encoder_format}
  
      codec_config (CodecConfig or None, optional): {codec_config}
  
      filter_desc (str or None, optional): {filter_desc}
  
      hw_accel (str or None, optional): Enable hardware acceleration.
  
          When video is encoded on CUDA hardware, for example
          `encoder="h264_nvenc"`, passing CUDA device indicator to `hw_accel`
          (i.e. `hw_accel="cuda:0"`) will make StreamingMediaEncoder expect video
          chunk to be CUDA Tensor. Passing CPU Tensor will result in an error.
  
          If `None`, the video chunk Tensor has to be CPU Tensor.
          Default: ``None``.
docstr_tok: ["Add","an","output","video","stream",".","This","method","has","to","be","called","before","`","open","`","is","called",".","Args",":","frame_rate","(","float",")",":","Frame","rate","of","the","video",".","width","(","int",")",":","Width","of","the","video","frame",".","height","(","int",")",":","Height","of","the","video","frame",".","format","(","str",",","optional",")",":","Input","pixel","format",",","which","determines","the","color","channel","order","of","the","input","tensor",".","-","``","``","gray8","''","``",":","One","channel",",","grayscale",".","-","``","``","rgb24","''","``",":","Three","channels","in","the","order","of","RGB",".","-","``","``","bgr24","''","``",":","Three","channels","in","the","order","of","BGR",".","-","``","``","yuv444p","''","``",":","Three","channels","in","the","order","of","YUV",".","Default",":","``","``","rgb24","''","``",".","In","either","case",",","the","input","tensor","has","to","be","``","torch.uint8","``","type","and","the","shape","must","be","(","frame",",","channel",",","height",",","width",")",".","encoder","(","str","or","None",",","optional",")",":","{","encoder","}","encoder_option","(","dict","or","None",",","optional",")",":","{","encoder_option","}","encoder_frame_rate","(","float","or","None",",","optional",")",":","Override","the","frame","rate","used","for","encoding",".","Some","encoders",",","(","such","as","``","``","mpeg1","''","``","and","``","``","mpeg2","''","``",")","pose","restriction","on","the","frame","rate","that","can","be","used","for","encoding",".","If","such","case",",","if","the","source","frame","rate","(","provided","as","``","frame_rate","``",")","is","not","one","of","the","supported","frame","rate",",","then","a","default","one","is","picked",",","and","the","frame","rate","is","changed","on-the-fly",".","Otherwise","the","source","frame","rate","is","used",".","Providing","``","encoder_frame_rate","``","will","override","this","behavior","and","make","encoder","attempts","to","use","the","provided","sample","rate",".","The","provided","value","must","be","one","support","by","the","encoder",".","encoder_width","(","int","or","None",",","optional",")",":","Width","of","the","image","used","for","encoding",".","This","allows","to","change","the","image","size","during","encoding",".","encoder_height","(","int","or","None",",","optional",")",":","Height","of","the","image","used","for","encoding",".","This","allows","to","change","the","image","size","during","encoding",".","encoder_format","(","str","or","None",",","optional",")",":","{","encoder_format","}","codec_config","(","CodecConfig","or","None",",","optional",")",":","{","codec_config","}","filter_desc","(","str","or","None",",","optional",")",":","{","filter_desc","}","hw_accel","(","str","or","None",",","optional",")",":","Enable","hardware","acceleration",".","When","video","is","encoded","on","CUDA","hardware",",","for","example","`","encoder=","''","h264_nvenc","''","`",",","passing","CUDA","device","indicator","to","`","hw_accel","`","(","i.e",".","`","hw_accel=","''","cuda:0","''","`",")","will","make","StreamingMediaEncoder","expect","video","chunk","to","be","CUDA","Tensor",".","Passing","CPU","Tensor","will","result","in","an","error",".","If","`","None","`",",","the","video","chunk","Tensor","has","to","be","CPU","Tensor",".","Default",":","``","None","``","."]
code: def add_video_stream(
      self,
      frame_rate: float,
      width: int,
      height: int,
      format: str = "rgb24",
      *,
      encoder: Optional[str] = None,
      encoder_option: Optional[Dict[str, str]] = None,
      encoder_frame_rate: Optional[float] = None,
      encoder_width: Optional[int] = None,
      encoder_height: Optional[int] = None,
      encoder_format: Optional[str] = None,
      codec_config: Optional[CodecConfig] = None,
      filter_desc: Optional[str] = None,
      hw_accel: Optional[str] = None,
  ):
      """Add an output video stream.
  
      This method has to be called before `open` is called.
  
      Args:
          frame_rate (float): Frame rate of the video.
  
          width (int): Width of the video frame.
  
          height (int): Height of the video frame.
  
          format (str, optional): Input pixel format, which determines the
              color channel order of the input tensor.
  
              - ``"gray8"``: One channel, grayscale.
              - ``"rgb24"``: Three channels in the order of RGB.
              - ``"bgr24"``: Three channels in the order of BGR.
              - ``"yuv444p"``: Three channels in the order of YUV.
  
              Default: ``"rgb24"``.
  
              In either case, the input tensor has to be ``torch.uint8`` type and
              the shape must be (frame, channel, height, width).
  
          encoder (str or None, optional): {encoder}
  
          encoder_option (dict or None, optional): {encoder_option}
  
          encoder_frame_rate (float or None, optional): Override the frame rate used for encoding.
  
              Some encoders, (such as ``"mpeg1"`` and ``"mpeg2"``) pose restriction on the
              frame rate that can be used for encoding.
              If such case, if the source frame rate (provided as ``frame_rate``) is not
              one of the supported frame rate, then a default one is picked, and the frame rate
              is changed on-the-fly. Otherwise the source frame rate is used.
  
              Providing ``encoder_frame_rate`` will override this behavior and
              make encoder attempts to use the provided sample rate.
              The provided value must be one support by the encoder.
  
          encoder_width (int or None, optional): Width of the image used for encoding.
              This allows to change the image size during encoding.
  
          encoder_height (int or None, optional): Height of the image used for encoding.
              This allows to change the image size during encoding.
  
          encoder_format (str or None, optional): {encoder_format}
  
          codec_config (CodecConfig or None, optional): {codec_config}
  
          filter_desc (str or None, optional): {filter_desc}
  
          hw_accel (str or None, optional): Enable hardware acceleration.
  
              When video is encoded on CUDA hardware, for example
              `encoder="h264_nvenc"`, passing CUDA device indicator to `hw_accel`
              (i.e. `hw_accel="cuda:0"`) will make StreamingMediaEncoder expect video
              chunk to be CUDA Tensor. Passing CPU Tensor will result in an error.
  
              If `None`, the video chunk Tensor has to be CPU Tensor.
              Default: ``None``.
      """
      self._s.add_video_stream(
          frame_rate,
          width,
          height,
          format,
          encoder,
          encoder_option,
          encoder_format,
          encoder_frame_rate,
          encoder_width,
          encoder_height,
          hw_accel,
          _convert_config(codec_config),
          filter_desc,
      )
  
imports: from dataclasses import dataclass
  from pathlib import Path
  from typing import BinaryIO, Dict, Optional, Union
  import torch
  import torio
label_desc: Use image node_id 3 for calling the StreamingMediaEncoder obj's underlying member method code with example usage: obj.add_video_stream(frame_rate, width, height, format) without return types