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: Converts the given image into a dict convertible to tf example.
docstr_tok: ["Converts","the","given","image","into","a","dict","convertible","to","tf","example","."]
code: def encode_example(self, video_or_path_or_fobj):
      """Converts the given image into a dict convertible to tf example."""
      if isinstance(video_or_path_or_fobj, epath.PathLikeCls):
          video_or_path_or_fobj = os.fspath(video_or_path_or_fobj)
          if not os.path.isfile(video_or_path_or_fobj):
              _, video_temp_path = tempfile.mkstemp()
              try:
                  tf.io.gfile.copy(
                      video_or_path_or_fobj,
                      video_temp_path,
                      overwrite=True,
                  )
                  encoded_video = self._ffmpeg_decode(video_temp_path)
              finally:
                  os.unlink(video_temp_path)
          else:
              encoded_video = self._ffmpeg_decode(video_or_path_or_fobj)
      elif isinstance(video_or_path_or_fobj, bytes):
          with tempfile.TemporaryDirectory() as tmpdirname:
              video_temp_path = os.path.join(tmpdirname, "video")
              with tf.io.gfile.GFile(video_temp_path, "wb") as f:
                  f.write(video_or_path_or_fobj)
              encoded_video = self._ffmpeg_decode(video_temp_path)
      elif hasattr(video_or_path_or_fobj, "read"):
          encoded_video = self._ffmpeg_decode(video_or_path_or_fobj)
      else:  # List of images, np.array,...
          encoded_video = video_or_path_or_fobj
      return super(Video, self).encode_example(encoded_video)
  
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 3 for calling the Video obj's underlying member method code with example usage: obj.encode_example(video_or_path_or_fobj) and returns: super