class_docstr: Accessing clips from an encoded video using Torchvision video reading API
  (torch.ops.video_reader.read_video_from_memory) as the decoding backend.
class_docstr_tok: ["Accessing","clips","from","an","encoded","video","using","Torchvision","video","reading","API","(","torch.ops.video_reader.read_video_from_memory",")","as","the","decoding","backend","."]
code: def __init__(
      self,
      file: BinaryIO,
      video_name: Optional[str] = None,
      decode_video: bool = True,
      decode_audio: bool = True,
  ) -> None:
      if not decode_video:
          raise NotImplementedError()
  
      self._video_tensor = torch.tensor(
          np.frombuffer(file.getvalue(), dtype=np.uint8)
      )
      self._video_name = video_name
      self._decode_audio = decode_audio
  
      (
          self._video,
          self._video_time_base,
          self._video_start_pts,
          video_duration,
          self._audio,
          self._audio_time_base,
          self._audio_start_pts,
          audio_duration,
      ) = self._torch_vision_decode_video()
  
      # Take the largest duration of either video or duration stream.
      if audio_duration is not None and video_duration is not None:
          self._duration = max(
              pts_to_secs(
                  video_duration,
                  self._video_time_base,
                  self._video_start_pts,
              ),
              pts_to_secs(
                  audio_duration,
                  self._audio_time_base,
                  self._audio_start_pts,
              ),
          )
      elif video_duration is not None:
          self._duration = pts_to_secs(
              video_duration,
              self._video_time_base,
              self._video_start_pts,
          )
  
      elif audio_duration is not None:
          self._duration = pts_to_secs(
              audio_duration,
              self._audio_time_base,
              self._audio_start_pts,
          )
  
file_path: pytorchvideo/pytorchvideo/data/encoded_video_torchvision.py
imports: import logging
  from fractions import Fraction
  from typing import BinaryIO, Dict, Optional
  import numpy
  import torch
  from .utils import pts_to_secs, secs_to_pts, thwc_to_cthw
  from .video import Video
label_desc: Use image node_id 1 to create a new EncodedVideoTorchVision object from inherited base classes: Video with example: obj = EncodedVideoTorchVision(file, video_name, decode_video, decode_audio)