o
    ϯi                     @   sl   d dl Z d dlZd dlZd dlmZ d dlmZ ddlmZ e	e
Zdedefdd	ZG d
d deZdS )    N)	g_pathmgr)DecoderType   )Videodecoderreturnc                 C   st   t | t jkrddlm} |}|S t | t jkr"ddlm} |}|S t | t jkr3ddlm	} |}|S t
d|  )z
    Select the class for accessing clips based on provided decoder string

    Args:
        decoder (str): Defines what type of decoder used to decode a video.
    r   )EncodedVideoPyAV)EncodedVideoTorchVision)EncodedVideoDecordzUnknown decoder type )r   PYAVencoded_video_pyavr   TORCHVISIONencoded_video_torchvisionr	   DECORDencoded_video_decordr
   NotImplementedError)r   r   	video_clsr	   r
    r   S/home/ubuntu/.local/lib/python3.10/site-packages/pytorchvideo/data/encoded_video.pyselect_video_class   s   r   c                   @   s.   e Zd ZdZe	d
dededefddZd	S )EncodedVideoz
    EncodedVideo is an abstraction for accessing clips from an encoded video.
    It supports selective decoding when header information is available.
    Tpyav	file_pathdecode_audior   c                 C   sV   t |d}t| }W d   n1 sw   Y  t|}||t|j|S )z
        Fetches the given video path using PathManager (allowing remote uris to be
        fetched) and constructs the EncodedVideo object.

        Args:
            file_path (str): a PathManager file-path.
        rbN)	r   openioBytesIOreadr   pathlibPathname)clsr   r   r   fh
video_filer   r   r   r   	from_path/   s
   zEncodedVideo.from_pathN)Tr   )__name__
__module____qualname____doc__classmethodstrboolr%   r   r   r   r   r   )   s    r   )r   loggingr   iopath.common.file_ior   pytorchvideo.data.decoderr   videor   	getLoggerr&   loggerr+   r   r   r   r   r   r   <module>   s   
