class_docstr: Accessing clips from an encoded video using Decord video reading API
  as the decoding backend. For more details, please refer to -
  `Decord <https://github.com/dmlc/decord>`
class_docstr_tok: ["Accessing","clips","from","an","encoded","video","using","Decord","video","reading","API","as","the","decoding","backend",".","For","more","details",",","please","refer","to","-","`","Decord","<","https",":","\/\/github.com\/dmlc\/decord",">","`"]
docstr: Args:
      file (BinaryIO): a file-like object (e.g. io.BytesIO or io.StringIO) that
          contains the encoded video.
      video_name (str): An optional name assigned to the video.
      decode_video (bool): If disabled, video is not decoded.
      decode_audio (bool): If disabled, audio is not decoded.
      sample_rate: int, default is -1
          Desired output sample rate of the audio, unchanged if `-1` is specified.
      mono: bool, default is True
          Desired output channel layout of the audio. `True` is mono layout. `False`
          is unchanged.
      width : int, default is -1
          Desired output width of the video, unchanged if `-1` is specified.
      height : int, default is -1
          Desired output height of the video, unchanged if `-1` is specified.
      num_threads : int, default is 0
          Number of decoding thread, auto if `0` is specified.
      fault_tol : int, default is -1
          The threshold of corupted and recovered frames. This is to prevent silent fault
          tolerance when for example 50% frames of a video cannot be decoded and duplicate
          frames are returned. You may find the fault tolerant feature sweet in many
          cases, but not for training models. Say `N = # recovered frames`
          If `fault_tol` < 0, nothing will happen.
          If 0 < `fault_tol` < 1.0, if N > `fault_tol * len(video)`,
          raise `DECORDLimitReachedError`.
          If 1 < `fault_tol`, if N > `fault_tol`, raise `DECORDLimitReachedError`.
docstr_tok: ["Args",":","file","(","BinaryIO",")",":","a","file-like","object","(","e.g",".","io.BytesIO","or","io.StringIO",")","that","contains","the","encoded","video",".","video_name","(","str",")",":","An","optional","name","assigned","to","the","video",".","decode_video","(","bool",")",":","If","disabled",",","video","is","not","decoded",".","decode_audio","(","bool",")",":","If","disabled",",","audio","is","not","decoded",".","sample_rate",":","int",",","default","is","-1","Desired","output","sample","rate","of","the","audio",",","unchanged","if","`","-1","`","is","specified",".","mono",":","bool",",","default","is","True","Desired","output","channel","layout","of","the","audio",".","`","True","`","is","mono","layout",".","`","False","`","is","unchanged",".","width",":","int",",","default","is","-1","Desired","output","width","of","the","video",",","unchanged","if","`","-1","`","is","specified",".","height",":","int",",","default","is","-1","Desired","output","height","of","the","video",",","unchanged","if","`","-1","`","is","specified",".","num_threads",":","int",",","default","is","0","Number","of","decoding","thread",",","auto","if","`","0","`","is","specified",".","fault_tol",":","int",",","default","is","-1","The","threshold","of","corupted","and","recovered","frames",".","This","is","to","prevent","silent","fault","tolerance","when","for","example","50","%","frames","of","a","video","can","not","be","decoded","and","duplicate","frames","are","returned",".","You","may","find","the","fault","tolerant","feature","sweet","in","many","cases",",","but","not","for","training","models",".","Say","`","N","=","#","recovered","frames","`","If","`","fault_tol","`","<","0",",","nothing","will","happen",".","If","0","<","`","fault_tol","`","<","1.0",",","if","N",">","`","fault_tol","*","len","(","video",")","`",",","raise","`","DECORDLimitReachedError","`",".","If","1","<","`","fault_tol","`",",","if","N",">","`","fault_tol","`",",","raise","`","DECORDLimitReachedError","`","."]
code: def __init__(
      self,
      file: BinaryIO,
      video_name: Optional[str] = None,
      decode_video: bool = True,
      decode_audio: bool = True,
      sample_rate: int = 44100,
      mono: bool = True,
      width: int = -1,
      height: int = -1,
      num_threads: int = 0,
      fault_tol: int = -1,
  ) -> None:
      """
      Args:
          file (BinaryIO): a file-like object (e.g. io.BytesIO or io.StringIO) that
              contains the encoded video.
          video_name (str): An optional name assigned to the video.
          decode_video (bool): If disabled, video is not decoded.
          decode_audio (bool): If disabled, audio is not decoded.
          sample_rate: int, default is -1
              Desired output sample rate of the audio, unchanged if `-1` is specified.
          mono: bool, default is True
              Desired output channel layout of the audio. `True` is mono layout. `False`
              is unchanged.
          width : int, default is -1
              Desired output width of the video, unchanged if `-1` is specified.
          height : int, default is -1
              Desired output height of the video, unchanged if `-1` is specified.
          num_threads : int, default is 0
              Number of decoding thread, auto if `0` is specified.
          fault_tol : int, default is -1
              The threshold of corupted and recovered frames. This is to prevent silent fault
              tolerance when for example 50% frames of a video cannot be decoded and duplicate
              frames are returned. You may find the fault tolerant feature sweet in many
              cases, but not for training models. Say `N = # recovered frames`
              If `fault_tol` < 0, nothing will happen.
              If 0 < `fault_tol` < 1.0, if N > `fault_tol * len(video)`,
              raise `DECORDLimitReachedError`.
              If 1 < `fault_tol`, if N > `fault_tol`, raise `DECORDLimitReachedError`.
      """
      if not decode_video:
          raise NotImplementedError()
  
      self._decode_audio = decode_audio
      self._video_name = video_name
      if not _HAS_DECORD:
          raise ImportError(
              "decord is required to use EncodedVideoDecord decoder. Please "
              "install with 'pip install decord' for CPU-only version and refer to"
              "'https://github.com/dmlc/decord' for GPU-supported version"
          )
      try:
          if self._decode_audio:
              self._av_reader = decord.AVReader(
                  uri=file,
                  ctx=decord.cpu(0),
                  sample_rate=sample_rate,
                  mono=mono,
                  width=width,
                  height=height,
                  num_threads=num_threads,
                  fault_tol=fault_tol,
              )
          else:
              self._av_reader = decord.VideoReader(
                  uri=file,
                  ctx=decord.cpu(0),
                  width=width,
                  height=height,
                  num_threads=num_threads,
                  fault_tol=fault_tol,
              )
      except Exception as e:
          raise RuntimeError(
              f"Failed to open video {video_name} with Decord. {e}"
          )
  
      if self._decode_audio:
          self._fps = (
              self._av_reader._AVReader__video_reader.get_avg_fps()
          )
      else:
          self._fps = self._av_reader.get_avg_fps()
  
      self._duration = float(len(self._av_reader)) / float(self._fps)
  
file_path: pytorchvideo/pytorchvideo/data/encoded_video_decord.py
imports: import logging
  import math
  from typing import BinaryIO, Dict, Optional, TypeVar
  import torch
  from .utils import thwc_to_cthw
  from .video import Video
label_desc: Use image node_id 1 to create a new EncodedVideoDecord object from inherited base classes: Video with example: obj = EncodedVideoDecord(file, video_name, decode_video, decode_audio, sample_rate, mono, width, height, num_threads, fault_tol)