class_docstr: `FeatureConnector` for videos, encoding frames individually on disk.
  
  Video: The image connector accepts as input a 4 dimensional `tf.uint8` array
  representing a video, a sequence of paths to encoded frames, or a path or a
  file object that can be decoded with ffmpeg. Note that not all formats in
  ffmpeg support reading from pipes, so providing a file object might fail.
  Furthermore, if a path is given that is not on the local file system, we first
  copy it to a temporary local file before passing it to ffmpeg.
  
  Output:
    video: tf.Tensor of type `tf.uint8` and shape
      [num_frames, height, width, channels], where channels must be 1 or 3
  
  Example:
  
    * In the DatasetInfo object:
  
    ```
    features=features.FeatureDict({
        'video': features.Video(shape=(None, 64, 64, 3)),
    })
    ```
  
    * During generation, you can use any of:
  
    ```
    yield {
        'video': np.ones(shape=(128, 64, 64, 3), dtype=np.uint8),
    }
    ```
  
    or list of frames:
  
    ```
    yield {
        'video': ['path/to/frame001.png', 'path/to/frame002.png'],
    }
    ```
  
    or path to video (including `os.PathLike` objects):
  
    ```
    yield {
        'video': '/path/to/video.avi',
    }
    ```
  
    or file object (or `bytes`):
  
    ```
    yield {
        'video': tf.io.gfile.GFile('/complex/path/video.avi'),
    }
    ```
class_docstr_tok: ["`","FeatureConnector","`","for","videos",",","encoding","frames","individually","on","disk",".","Video",":","The","image","connector","accepts","as","input","a","4","dimensional","`","tf.uint8","`","array","representing","a","video",",","a","sequence","of","paths","to","encoded","frames",",","or","a","path","or","a","file","object","that","can","be","decoded","with","ffmpeg",".","Note","that","not","all","formats","in","ffmpeg","support","reading","from","pipes",",","so","providing","a","file","object","might","fail",".","Furthermore",",","if","a","path","is","given","that","is","not","on","the","local","file","system",",","we","first","copy","it","to","a","temporary","local","file","before","passing","it","to","ffmpeg",".","Output",":","video",":","tf.Tensor","of","type","`","tf.uint8","`","and","shape","[","num_frames",",","height",",","width",",","channels","]",",","where","channels","must","be","1","or","3","Example",":","*","In","the","DatasetInfo","object",":","``","`","features=features.FeatureDict","(","{","'video","'",":","features.Video","(","shape=","(","None",",","64",",","64",",","3",")",")",",","}",")","``","`","*","During","generation",",","you","can","use","any","of",":","``","`","yield","{","'video","'",":","np.ones","(","shape=","(","128",",","64",",","64",",","3",")",",","dtype=np.uint8",")",",","}","``","`","or","list","of","frames",":","``","`","yield","{","'video","'",":","[","'path\/to\/frame001.png","'",",","'path\/to\/frame002.png","'","]",",","}","``","`","or","path","to","video","(","including","`","os.PathLike","`","objects",")",":","``","`","yield","{","'video","'",":","'\/path\/to\/video.avi","'",",","}","``","`","or","file","object","(","or","`","bytes","`",")",":","``","`","yield","{","'video","'",":","tf.io.gfile.GFile","(","'\/complex\/path\/video.avi","'",")",",","}","``","`"]
docstr: Initializes the connector.
  
  Args:
    shape: tuple of ints, the shape of the video (num_frames, height, width,
      channels), where channels is 1 or 3.
    encoding_format: The video is stored as a sequence of encoded images. You
      can use any encoding format supported by image_feature.Feature.
    ffmpeg_extra_args: A sequence of additional args to be passed to the
      ffmpeg binary. Specifically, ffmpeg will be called as: `` ffmpeg -i
      <input_file> <ffmpeg_extra_args> %010d.<encoding_format> ``
    use_colormap: Forwarded to `tfds.features.Image`. If `True`,
      `tfds.as_dataframe` will display each value in the image with a
      different color.
    dtype: tf.uint16 or tf.uint8 (default). tf.uint16 can be used only with
      png encoding_format
    doc: Documentation of this feature (e.g. description).
  
  Raises:
    ValueError: If the shape is invalid
docstr_tok: ["Initializes","the","connector",".","Args",":","shape",":","tuple","of","ints",",","the","shape","of","the","video","(","num_frames",",","height",",","width",",","channels",")",",","where","channels","is","1","or","3.","encoding_format",":","The","video","is","stored","as","a","sequence","of","encoded","images",".","You","can","use","any","encoding","format","supported","by","image_feature.Feature",".","ffmpeg_extra_args",":","A","sequence","of","additional","args","to","be","passed","to","the","ffmpeg","binary",".","Specifically",",","ffmpeg","will","be","called","as",":","``","ffmpeg","-i","<","input_file",">","<","ffmpeg_extra_args",">","%","010d.","<","encoding_format",">","``","use_colormap",":","Forwarded","to","`","tfds.features.Image","`",".","If","`","True","`",",","`","tfds.as_dataframe","`","will","display","each","value","in","the","image","with","a","different","color",".","dtype",":","tf.uint16","or","tf.uint8","(","default",")",".","tf.uint16","can","be","used","only","with","png","encoding_format","doc",":","Documentation","of","this","feature","(","e.g",".","description",")",".","Raises",":","ValueError",":","If","the","shape","is","invalid"]
code: def __init__(
      self,
      shape: Sequence[Optional[int]],
      encoding_format: str = "png",
      ffmpeg_extra_args: Sequence[str] = (),
      use_colormap: bool = False,
      dtype: Union[np.uint8, tf.uint8, np.uint16, tf.uint16] = np.uint8,
      doc: feature_lib.DocArg = None,
  ):
      """Initializes the connector.
  
      Args:
        shape: tuple of ints, the shape of the video (num_frames, height, width,
          channels), where channels is 1 or 3.
        encoding_format: The video is stored as a sequence of encoded images. You
          can use any encoding format supported by image_feature.Feature.
        ffmpeg_extra_args: A sequence of additional args to be passed to the
          ffmpeg binary. Specifically, ffmpeg will be called as: `` ffmpeg -i
          <input_file> <ffmpeg_extra_args> %010d.<encoding_format> ``
        use_colormap: Forwarded to `tfds.features.Image`. If `True`,
          `tfds.as_dataframe` will display each value in the image with a
          different color.
        dtype: tf.uint16 or tf.uint8 (default). tf.uint16 can be used only with
          png encoding_format
        doc: Documentation of this feature (e.g. description).
  
      Raises:
        ValueError: If the shape is invalid
      """
      dtype = tf.dtypes.as_dtype(dtype)
      shape = tuple(shape)
      if len(shape) != 4:
          raise ValueError("Video shape should be of rank 4")
      self._encoding_format = encoding_format
      self._extra_ffmpeg_args = list(ffmpeg_extra_args or [])
      super(Video, self).__init__(
          image_feature.Image(
              shape=shape[1:],
              dtype=dtype,
              encoding_format=encoding_format,
              use_colormap=use_colormap,
          ),
          length=shape[0],
      )
  
imports: from __future__ import annotations
  import os
  import tempfile
  from typing import Optional, Sequence, Union
  from etils import epath
  import numpy
  from tensorflow_datasets.core import utils
  from tensorflow_datasets.core.features import feature
  from tensorflow_datasets.core.features import image_feature
  from tensorflow_datasets.core.features import sequence_feature
  from tensorflow_datasets.core.proto import feature_pb2
  from tensorflow_datasets.core.utils import type_utils
  from tensorflow_datasets.core.utils.lazy_imports_utils import tensorflow
label_desc: Use image node_id 1 to create a new Video object from inherited base classes: sequence_feature with example: obj = Video(shape, encoding_format, ffmpeg_extra_args, use_colormap, dtype, doc)