class_docstr: EncodedVideoPyAV is an abstraction for accessing clips from an encoded video using
  PyAV as the decoding backend. It supports selective decoding when header information
  is available.
class_docstr_tok: ["EncodedVideoPyAV","is","an","abstraction","for","accessing","clips","from","an","encoded","video","using","PyAV","as","the","decoding","backend",".","It","supports","selective","decoding","when","header","information","is","available","."]
docstr: Selectively decodes a video between start_pts and end_pts in time units of the
  self._video's timebase.
docstr_tok: ["Selectively","decodes","a","video","between","start_pts","and","end_pts","in","time","units","of","the","self._video","'s","timebase","."]
code: def _pyav_decode_video(
      self, start_secs: float = 0.0, end_secs: float = math.inf
  ) -> float:
      """
      Selectively decodes a video between start_pts and end_pts in time units of the
      self._video's timebase.
      """
      video_and_pts = None
      audio_and_pts = None
      try:
          if self._decode_video:
              pyav_video_frames, _ = _pyav_decode_stream(
                  self._container,
                  secs_to_pts(
                      start_secs,
                      self._video_time_base,
                      self._video_start_pts,
                      round_mode="ceil",
                  ),
                  secs_to_pts(
                      end_secs,
                      self._video_time_base,
                      self._video_start_pts,
                      round_mode="ceil",
                  ),
                  self._container.streams.video[0],
                  {"video": 0},
                  perform_seek=self.perform_seek,
              )
              if len(pyav_video_frames) > 0:
                  video_and_pts = [
                      (
                          torch.from_numpy(frame.to_rgb().to_ndarray()),
                          frame.pts,
                      )
                      for frame in pyav_video_frames
                  ]
  
          if self._has_audio:
              pyav_audio_frames, _ = _pyav_decode_stream(
                  self._container,
                  secs_to_pts(
                      start_secs,
                      self._audio_time_base,
                      self._audio_start_pts,
                      round_mode="ceil",
                  ),
                  secs_to_pts(
                      end_secs,
                      self._audio_time_base,
                      self._audio_start_pts,
                      round_mode="ceil",
                  ),
                  self._container.streams.audio[0],
                  {"audio": 0},
                  perform_seek=self.perform_seek,
              )
  
              if len(pyav_audio_frames) > 0:
                  audio_and_pts = [
                      (
                          torch.from_numpy(
                              np.mean(frame.to_ndarray(), axis=0)
                          ),
                          frame.pts,
                      )
                      for frame in pyav_audio_frames
                  ]
  
      except Exception as e:
          logger.debug(
              f"Failed to decode video: {self._video_name}. {e}"
          )
  
      return video_and_pts, audio_and_pts
  
imports: import logging
  import math
  from fractions import Fraction
  from typing import BinaryIO, Dict, List, Optional, Tuple, Union
  import av
  import numpy
  import torch
  from pytorchvideo.data.encoded_video import EncodedVideo
  from .utils import pts_to_secs, secs_to_pts, thwc_to_cthw
label_desc: Use image node_id 9 for calling the EncodedVideoPyAV obj's underlying member method code with example usage: obj._pyav_decode_video(start_secs, end_secs) and returns: video_and_pts,  audio_and_pts