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","."]
docstr: Retrieves frames from the encoded video at the specified start and end times
  in seconds (the video always starts at 0 seconds). Returned frames will be in
  [start_sec, end_sec). Note that 1) if you want to avoid float precision issue
  and need accurate frames, please use Fraction for start_sec and end_sec.
  2) As end_sec is exclusive, so you may need to use
  `get_clip(start_sec, duration + EPS)` to get the last frame.
  
  Args:
      start_sec (float): the clip start time in seconds
      end_sec (float): the clip end time in seconds
  Returns:
      clip_data:
          A dictionary mapping the entries at "video" and "audio" to a tensors.
  
          "video": A tensor of the clip's RGB frames with shape:
          (channel, time, height, width). The frames are of type torch.float32 and
          in the range [0 - 255].
  
          "audio": A tensor of the clip's audio samples with shape:
          (samples). The samples are of type torch.float32 and
          in the range [0 - 255].
  
      Returns None if no video or audio found within time range.
docstr_tok: ["Retrieves","frames","from","the","encoded","video","at","the","specified","start","and","end","times","in","seconds","(","the","video","always","starts","at","0","seconds",")",".","Returned","frames","will","be","in","[","start_sec",",","end_sec",")",".","Note","that","1",")","if","you","want","to","avoid","float","precision","issue","and","need","accurate","frames",",","please","use","Fraction","for","start_sec","and","end_sec",".","2",")","As","end_sec","is","exclusive",",","so","you","may","need","to","use","`","get_clip","(","start_sec",",","duration","+","EPS",")","`","to","get","the","last","frame",".","Args",":","start_sec","(","float",")",":","the","clip","start","time","in","seconds","end_sec","(","float",")",":","the","clip","end","time","in","seconds","Returns",":","clip_data",":","A","dictionary","mapping","the","entries","at","``","video","''","and","``","audio","''","to","a","tensors",".","``","video","''",":","A","tensor","of","the","clip","'s","RGB","frames","with","shape",":","(","channel",",","time",",","height",",","width",")",".","The","frames","are","of","type","torch.float32","and","in","the","range","[","0","-","255","]",".","``","audio","''",":","A","tensor","of","the","clip","'s","audio","samples","with","shape",":","(","samples",")",".","The","samples","are","of","type","torch.float32","and","in","the","range","[","0","-","255","]",".","Returns","None","if","no","video","or","audio","found","within","time","range","."]
code: def get_clip(
      self, start_sec: float, end_sec: float
  ) -> Dict[str, Optional[torch.Tensor]]:
      """
      Retrieves frames from the encoded video at the specified start and end times
      in seconds (the video always starts at 0 seconds). Returned frames will be in
      [start_sec, end_sec). Note that 1) if you want to avoid float precision issue
      and need accurate frames, please use Fraction for start_sec and end_sec.
      2) As end_sec is exclusive, so you may need to use
      `get_clip(start_sec, duration + EPS)` to get the last frame.
  
      Args:
          start_sec (float): the clip start time in seconds
          end_sec (float): the clip end time in seconds
      Returns:
          clip_data:
              A dictionary mapping the entries at "video" and "audio" to a tensors.
  
              "video": A tensor of the clip's RGB frames with shape:
              (channel, time, height, width). The frames are of type torch.float32 and
              in the range [0 - 255].
  
              "audio": A tensor of the clip's audio samples with shape:
              (samples). The samples are of type torch.float32 and
              in the range [0 - 255].
  
          Returns None if no video or audio found within time range.
  
      """
      video_frames = None
      if self._video is not None:
          video_start_pts = secs_to_pts(
              start_sec,
              self._video_time_base,
              self._video_start_pts,
              round_mode="ceil",
          )
          video_end_pts = secs_to_pts(
              end_sec,
              self._video_time_base,
              self._video_start_pts,
              round_mode="ceil",
          )
          video_frames = [
              f
              for f, pts in self._video
              if pts >= video_start_pts and pts < video_end_pts
          ]
  
      audio_samples = None
      if self._decode_audio and self._audio:
          audio_start_pts = secs_to_pts(
              start_sec,
              self._audio_time_base,
              self._audio_start_pts,
              round_mode="ceil",
          )
          audio_end_pts = secs_to_pts(
              end_sec,
              self._audio_time_base,
              self._audio_start_pts,
              round_mode="ceil",
          )
          audio_samples = [
              f
              for f, pts in self._audio
              if pts >= audio_start_pts and pts < audio_end_pts
          ]
          audio_samples = torch.cat(audio_samples, axis=0)
          audio_samples = audio_samples.to(torch.float32)
  
      if video_frames is None or len(video_frames) == 0:
          logger.warning(
              f"No video found within {start_sec} and {end_sec} seconds. "
              f"Video starts at time 0 and ends at {self.duration}."
          )
  
          video_frames = None
  
      if video_frames is not None:
          video_frames = thwc_to_cthw(torch.stack(video_frames)).to(
              torch.float32
          )
  
      return {
          "video": video_frames,
          "audio": audio_samples,
      }
  
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 5 for calling the EncodedVideoTorchVision obj's underlying member method code with example usage: obj.get_clip(start_sec, end_sec) and returns: dict