§
    ù²Åj;H  ã                   óú  — d dl Z d dlZd dlZd dlZd dlZd dlmZ d dlmZm	Z	m
Z
mZmZmZ d dlZd dlZddlmZ ddlmZ 	 d dlZej                             ej        j        ¦  «          eej        j        j        d¦  «        s ed	¦  «        Z	 ej        Zn# e$ r
 ej         ZY nw xY wn# e$ r  ed
¦  «        ZY nw xY wd3d„Z!de"fd„Z#d a$da%	 	 	 	 	 	 d4de&dej'        de(de&dee	e&ef                  deej'                 dee(         dee&         dee	e&ef                  ddfd„Z)ddde(de(de&dd d!e	e&eee*ee*d"f         e
e*         f                  f         de
d#         fd$„Z+d%ej'        d&e
d#         d'e*d(e(dej'        f
d)„Z,	 	 	 	 d5de&d,ee(ef         d-eee(ef                  de&d.e&deej'        ej'        e	e&ef         f         fd/„Z-ddde"fd0„Z.ddde
e*         fd1„Z/d6de&de&dee
e*         ee(         f         fd2„Z0dS )7é    N)ÚFraction)ÚAnyÚDictÚListÚOptionalÚTupleÚUnioné   )Ú_log_api_usage_onceé   )Ú
_video_optÚ	pict_typea+  Your version of PyAV is too old for the necessary video operations in torchvision.
If you are on Python 3.5, you will have to build from source (the conda-forge
packages are not up-to-date).  See
https://github.com/mikeboers/PyAV#installation for instructions on how to
install PyAV on your system.
z¼PyAV is not installed, and is necessary for the video operations in torchvision.
See https://github.com/mikeboers/PyAV#installation for instructions on how to
install PyAV on your system.
Úreturnc                  óH   — t          t          t          ¦  «        rt          ‚d S ©N©Ú
isinstanceÚavÚ	Exception© ó    úEC:\Projects\Historical\venv\Lib\site-packages\torchvision/io/video.pyÚ_check_av_availabler   +   s#   € Ý•"•iÑ Ô ð Ýˆðð r   c                  ó8   — t          t          t          ¦  «         S r   r   r   r   r   Ú_av_availabler   0   s   € Ý�"�iÑ(Ô(Ð(Ð(r   é
   Úlibx264ÚfilenameÚvideo_arrayÚfpsÚvideo_codecÚoptionsÚaudio_arrayÚ	audio_fpsÚaudio_codecÚaudio_optionsc	                 óJ  — t           j                             ¦   «         s2t           j                             ¦   «         st	          t
          ¦  «         t          ¦   «          t          j        |t           j        ¬¦  «         	                    d¬¦  «        }t          |t          ¦  «        rt          j        |¦  «        }t          j        | d¬¦  «        5 }	|	                     ||¬¦  «        }
|j        d         |
_        |j        d         |
_        |d	k    rd
nd|
_        |pi |
_        |��7dddddddddddœ
}|	                     ||¬¦  «        }|pi |_        |j        d         }|dk    rdnd}|	j        j        d         j        j        }t          j        ||         ¦  «        }t          j        |¦  «         	                    d¬¦  «                             |¦  «        }t          j                             |||¬¦  «        }||_        |                     |¦  «        D ]}|	                      |¦  «         Œ|                     ¦   «         D ]}|	                      |¦  «         Œ|D ]{}t          j!                             |d¬¦  «        }	 d|_"        n"# tF          $ r ddl$m%} |j&        |_"        Y nw xY w|
                     |¦  «        D ]}|	                      |¦  «         ŒŒ||
                     ¦   «         D ]}|	                      |¦  «         Œ	 ddd¦  «         dS # 1 swxY w Y   dS )aM  
    Writes a 4d tensor in [T, H, W, C] format in a video file.

    This function relies on PyAV (therefore, ultimately FFmpeg) to encode
    videos, you can get more fine-grained control by referring to the other
    options at your disposal within `the FFMpeg wiki
    <http://trac.ffmpeg.org/wiki#Encoding>`_.

    .. warning::

        In the near future, we intend to centralize PyTorch's video decoding
        capabilities within the `torchcodec
        <https://github.com/pytorch/torchcodec>`_ project. We encourage you to
        try it out and share your feedback, as the torchvision video decoders
        will eventually be deprecated.

    Args:
        filename (str): path where the video will be saved
        video_array (Tensor[T, H, W, C]): tensor containing the individual frames,
            as a uint8 tensor in [T, H, W, C] format
        fps (Number): video frames per second
        video_codec (str): the name of the video codec, i.e. "libx264", "h264", etc.
        options (Dict): dictionary containing options to be passed into the PyAV video stream.
            The list of options is codec-dependent and can all
            be found from `the FFMpeg wiki <http://trac.ffmpeg.org/wiki#Encoding>`_.
        audio_array (Tensor[C, N]): tensor containing the audio, where C is the number of channels
            and N is the number of samples
        audio_fps (Number): audio sample rate, typically 44100 or 48000
        audio_codec (str): the name of the audio codec, i.e. "mp3", "aac", etc.
        audio_options (Dict): dictionary containing options to be passed into the PyAV audio stream.
            The list of options is codec-dependent and can all
            be found from `the FFMpeg wiki <http://trac.ffmpeg.org/wiki#Encoding>`_.

    Examples::
        >>> # Creating libx264 video with CRF 17, for visually lossless footage:
        >>>
        >>> from torchvision.io import write_video
        >>> # 1000 frames of 100x100, 3-channel image.
        >>> vid = torch.randn(1000, 100, 100, 3, dtype = torch.uint8)
        >>> write_video("video.mp4", options = {"crf": "17"})

    ©ÚdtypeT)ÚforceÚw)Úmode)Úrater
   r   Ú
libx264rgbÚyuv420pÚrgb24Nz<f8z<f4z<i2z<i4Úu1)
ÚdblÚdblpÚfltÚfltpÚs16Ús16pÚs32Ús32pÚu8Úu8pr   ÚstereoÚmono)ÚformatÚlayout)r>   ÚNONE)ÚPictureType)'ÚtorchÚjitÚis_scriptingÚ
is_tracingr   Úwrite_videor   Ú	as_tensorÚuint8Únumpyr   ÚfloatÚnpÚroundr   ÚopenÚ
add_streamÚshapeÚwidthÚheightÚpix_fmtr"   ÚstreamsÚaudior>   Únamer)   ÚastypeÚ
AudioFrameÚfrom_ndarrayÚsample_rateÚencodeÚmuxÚ
VideoFramer   Ú	TypeErrorÚav.video.framerA   r@   )r   r   r    r!   r"   r#   r$   r%   r&   Ú	containerÚstreamÚaudio_format_dtypesÚa_streamÚnum_channelsÚaudio_layoutÚaudio_sample_fmtÚformat_dtypeÚframeÚpacketÚimgrA   s                        r   rF   rF   9   s“  € õj Œ9×!Ò!Ñ#Ô#ð )­E¬I×,@Ò,@Ñ,BÔ,Bð )Ý�KÑ(Ô(Ð(ÝÑÔÐÝ”/ +µU´[ÐAÑAÔA×GÒGÈdÐGÑSÔS€Kõ �#•uÑÔð ÝŒh�s‰mŒmˆå	Œ� Ð	$Ñ	$Ô	$ð 6"¨	Ø×%Ò% k¸Ð%Ñ<Ô<ˆØ"Ô(¨Ô+ˆŒØ#Ô)¨!Ô,ˆŒØ&1°\Ò&AÐ&A˜˜ÀwˆŒØ ˜ BˆŒàÑ"àØØØØØØØØØð#ð #Ðð !×+Ò+¨K¸iÐ+ÑHÔHˆHØ,Ð2°ˆHÔà&Ô,¨QÔ/ˆLØ'3°aÒ'7Ð'7˜8˜8¸VˆLØ(Ô0Ô6°qÔ9Ô@ÔEÐåœ8Ð$7Ð8HÔ$IÑJÔJˆLÝœ/¨+Ñ6Ô6×<Ò<À4Ð<ÑHÔH×OÒOÐP\Ñ]Ô]ˆKå”M×.Ò.¨{ÐCSÐ\hÐ.ÑiÔiˆEà )ˆEÔà"Ÿ/š/¨%Ñ0Ô0ð &ð &�Ø—’˜fÑ%Ô%Ð%Ð%à"Ÿ/š/Ñ+Ô+ð &ð &�Ø—’˜fÑ%Ô%Ð%Ð%àð 
	&ð 
	&ˆCÝ”M×.Ò.¨s¸7Ð.ÑCÔCˆEð3Ø"(�”�øÝð 3ð 3ð 3Ø6Ð6Ð6Ð6Ð6Ð6à"-Ô"2�”��ð3øøøð
 !Ÿ-š-¨Ñ.Ô.ð &ð &�Ø—’˜fÑ%Ô%Ð%Ð%ð&ð —m’m‘o”oð 	"ð 	"ˆFØ�MŠM˜&Ñ!Ô!Ð!Ð!ð	"ðk6"ð 6"ð 6"ñ 6"ô 6"ð 6"ð 6"ð 6"ð 6"ð 6"ð 6"ð 6"øøøð 6"ð 6"ð 6"ð 6"ð 6"ð 6"s8   ÃF3LÊJÊLÊJ-Ê*LÊ,J-Ê-ALÌLÌLr_   zav.container.ContainerÚstart_offsetÚ
end_offsetÚpts_unitr`   zav.stream.StreamÚstream_name.zav.frame.Framec                 ó  ‡‡‡— t           dz  a t           t          z  t          dz
  k    rt          j        ¦   «          |dk    rlt	          t          j        ‰d|j        z  z  ¦  «        ¦  «        Š‰t          d¦  «        k    r,t	          t          j	        ‰d|j        z  z  ¦  «        ¦  «        Šnt          j        d¦  «         i Šd}d}|j        dk    rx|j        j        }|rjd|v rf|                     d¦  «        }	||	d …         }
t!          j        d	|
¦  «        }|€t!          j        d
|
¦  «        }|�|                     d¦  «        dk    }‰}t'          |dz
  d¦  «        }|rt'          ||z
  d¦  «        }	 |                      |dd|¬¦  «         n# t*          $ r g cY S w xY wd}	 t-           | j        di |¤Ž¦  «        D ]*\  }}|‰|j        <   |j        ‰k    r|r||k     r|dz  }Œ( nŒ+n# t*          $ r Y nw xY wˆˆˆfd„t3          ‰¦  «        D ¦   «         }t5          ‰¦  «        dk    rV‰dk    rP‰‰vrLˆfd„‰D ¦   «         }t5          |¦  «        dk    r+t'          |¦  «        }|                     d‰|         ¦  «         |S )Nr   ÚsecÚinfzBThe pts_unit 'pts' gives wrong results. Please use pts_unit 'sec'.Té   Úvideos   DivXs   DivX(\d+)Build(\d+)(\w)s   DivX(\d+)b(\d+)(\w)é   ó   pr   F)Ú	any_frameÚbackwardr`   c                 óV   •— g | ]%}‰‰|         j         cxk    r‰k    ¯n n‰|         ‘Œ&S r   ©Úpts)Ú.0Úirk   Úframesrj   s     €€€r   ú
<listcomp>z%_read_from_stream.<locals>.<listcomp>õ   sE   ø€ Ð_Ð_Ð_˜A°<À6È!Ä9Ä=Ð3^Ð3^Ò3^Ð3^ÐT^Ò3^Ð3^Ð3^Ð3^Ð3^ˆf�QŒiÐ3^Ð3^Ð3^r   c                 ó    •— g | ]
}|‰k     ¯|‘ŒS r   r   )rz   r{   rj   s     €r   r}   z%_read_from_stream.<locals>.<listcomp>ú   s#   ø€ ÐBÐBÐB !°°\Ò1AÐ1A˜AÐ1AÐ1AÐ1Ar   r   )Ú_CALLED_TIMESÚ_GC_COLLECTION_INTERVALÚgcÚcollectÚintÚmathÚfloorÚ	time_baserJ   ÚceilÚwarningsÚwarnÚtypeÚcodec_contextÚ	extradataÚfindÚreÚsearchÚgroupÚmaxÚseekÚFFmpegErrorÚ	enumerateÚdecodery   ÚsortedÚlenÚinsert)r_   rj   rk   rl   r`   rm   Úshould_bufferÚmax_buffer_sizerŒ   ÚposÚdÚoÚseek_offsetÚbuffer_countÚ_idxrg   ÚresultÚpreceding_framesÚfirst_frame_ptsr|   s    ``                @r   Ú_read_from_streamr¤   ±   s  øøø€ õ �QÑ€MÝÕ.Ñ.Õ2IÈAÑ2MÒMÐMÝ
Œ
‰Œˆà�5ÒÐõ �4œ: l°a¸&Ô:JÑ6JÑ&KÑLÔLÑMÔMˆØ�˜u™œÒ%Ð%Ý�TœY z°Q¸Ô9IÑ5IÑ'JÑKÔKÑLÔLˆJøåŒÐZÑ[Ô[Ð[à€FØ€MØ€OØ„{�gÒÐð Ô(Ô2ˆ	ð ð 	3˜ IÐ-Ð-à—.’. Ñ)Ô)ˆCØ˜#˜$˜$”ˆAÝ”	Ð5°qÑ9Ô9ˆAØˆyÝ”IÐ5°qÑ9Ô9�Øˆ}Ø !§¢¨¡
¤
¨dÒ 2�Ø€Kå�k A‘o qÑ)Ô)€KØð <õ ˜+¨Ñ7¸Ñ;Ô;ˆðà�Š�{¨e¸dÈ6ˆÑRÔRÐRÐRøÝð ð ð ð ˆ	ˆ	ˆ	ðøøøð €Lð
Ý$Ð%5 YÔ%5Ð%DÐ%D¸Ð%DÐ%DÑEÔEð 	ð 	‰KˆD�%Ø %ˆF�5”9ÑØŒy˜JÒ&Ð&Ø ð  \°OÒ%CÐ%CØ  AÑ%�LØØ�ð	 'øøõ
 ð ð ð àˆðøøøð `Ð_Ð_Ð_Ð_Ð_¥¨¡¤Ð_Ñ_Ô_€FÝ
ˆ6�{„{�Q‚€˜<¨!Ò+Ð+°ÀFÐ0JÐ0Jð CÐBÐBÐB vÐBÑBÔBÐÝÐÑ Ô  1Ò$Ð$Ý!Ð"2Ñ3Ô3ˆOØ�MŠM˜!˜V OÔ4Ñ5Ô5Ð5Ø€Ms%   Å6F ÆFÆFÆ%AG+ Ç+
G8Ç7G8ÚaframesÚaudio_framesÚ	ref_startÚref_endc                 óö   — |d         j         |d         j         }}| j        d         }||z
  dz   |z  }d}|}	||k     rt          ||z
  |z  ¦  «        }||k    rt          ||z
  |z  ¦  «        }	| d d …||	…f         S )Nr   éÿÿÿÿr   )ry   rO   rƒ   )
r¥   r¦   r§   r¨   ÚstartÚendÚtotal_aframesÚstep_per_aframeÚs_idxÚe_idxs
             r   Ú_align_audio_framesr±     sœ   € ð ˜a”Ô$ l°2Ô&6Ô&:ˆ3€EØ”M !Ô$€MØ˜U‘{ Q‘¨-Ñ7€OØ€EØ€EØˆyÒÐÝ�Y Ñ&¨/Ñ9Ñ:Ô:ˆØ
ˆW‚}€}Ý�W˜s‘] oÑ5Ñ6Ô6ˆØ�1�1�1�e˜E�k�>Ô"Ð"r   ry   ÚTHWCÚ	start_ptsÚend_ptsÚoutput_formatc           
      óþ  — t           j                             ¦   «         s2t           j                             ¦   «         st	          t
          ¦  «         |                     ¦   «         }|dvrt          d|› d�¦  «        ‚ddlm	}  |¦   «         dk    rNt          j                             | ¦  «        st          d| › �¦  «        ‚t          j        | |||¦  «        \  }}}�n~t!          ¦   «          |€t#          d	¦  «        }||k     rt          d
|› d|› �¦  «        ‚i }g }	g }
t          j        }	 t'          j        | d¬¦  «        5 }|j        j        r|j        j        d         j        }|j        j        rQt3          |||||j        j        d         ddi¦  «        }	|j        j        d         j        }|�t#          |¦  «        |d<   |j        j        r@t3          |||||j        j        d         ddi¦  «        }
|j        j        d         j        |d<   ddd¦  «         n# 1 swxY w Y   n# t8          $ r Y nw xY wd„ |	D ¦   «         }d„ |
D ¦   «         }|r't          j        t=          j        |¦  «        ¦  «        }n t          j         dt           j!        ¬¦  «        }|r£t=          j"        |d¦  «        }t          j        |¦  «        }|dk    ratG          tI          j%        |d|z  z  ¦  «        ¦  «        }|t#          d	¦  «        k    r'tG          tI          j&        |d|z  z  ¦  «        ¦  «        }tO          ||
||¦  «        }n t          j         dt           j(        ¬¦  «        }|dk    r| )                    dddd¦  «        }|||fS )a–  
    Reads a video from a file, returning both the video frames and the audio frames

    .. warning::

        In the near future, we intend to centralize PyTorch's video decoding
        capabilities within the `torchcodec
        <https://github.com/pytorch/torchcodec>`_ project. We encourage you to
        try it out and share your feedback, as the torchvision video decoders
        will eventually be deprecated.

    Args:
        filename (str): path to the video file. If using the pyav backend, this can be whatever ``av.open`` accepts.
        start_pts (int if pts_unit = 'pts', float / Fraction if pts_unit = 'sec', optional):
            The start presentation time of the video
        end_pts (int if pts_unit = 'pts', float / Fraction if pts_unit = 'sec', optional):
            The end presentation time
        pts_unit (str, optional): unit in which start_pts and end_pts values will be interpreted,
            either 'pts' or 'sec'. Defaults to 'pts'.
        output_format (str, optional): The format of the output video tensors. Can be either "THWC" (default) or "TCHW".

    Returns:
        vframes (Tensor[T, H, W, C] or Tensor[T, C, H, W]): the `T` video frames
        aframes (Tensor[K, L]): the audio frames, where `K` is the number of channels and `L` is the number of points
        info (Dict): metadata for the video and audio. Can contain the fields video_fps (float) and audio_fps (int)
    )r²   ÚTCHWz5output_format should be either 'THWC' or 'TCHW', got ú.r   ©Úget_video_backendÚpyavzFile not found: Nrp   z7end_pts should be larger than start_pts, got start_pts=z and end_pts=Úignore©Úmetadata_errorsrr   Ú	video_fpsrT   r$   c                 óZ   — g | ](}|                      ¦   «                              ¦   «         ‘Œ)S r   )Úto_rgbÚ
to_ndarray©rz   rg   s     r   r}   zread_video.<locals>.<listcomp>o  s,   € ÐNÐNÐN¸˜Ÿš™œ×1Ò1Ñ3Ô3ÐNÐNÐNr   c                 ó6   — g | ]}|                      ¦   «         ‘ŒS r   )rÂ   rÃ   s     r   r}   zread_video.<locals>.<listcomp>p  s$   € ÐEÐEÐE¨u˜×(Ò(Ñ*Ô*ÐEÐEÐEr   )r   r   r   rs   r(   r   ro   )r   r   r·   rs   r
   )*rB   rC   rD   rE   r   Ú
read_videoÚupperÚ
ValueErrorÚtorchvisionrº   ÚosÚpathÚexistsÚRuntimeErrorr   Ú_read_videor   rJ   Údefault_timebaser   rM   rS   rT   r†   rr   r¤   Úaverage_rater-   r“   rG   rK   ÚstackÚemptyrH   Úconcatenaterƒ   r„   r…   r‡   r±   Úfloat32Úpermute)r   r³   r´   rl   rµ   rº   Úvframesr¥   ÚinfoÚvideo_framesr¦   Úaudio_timebaser_   r¿   Úvframes_listÚaframes_lists                   r   rÅ   rÅ     s  € õB Œ9×!Ò!Ñ#Ô#ð (­E¬I×,@Ò,@Ñ,BÔ,Bð (Ý�JÑ'Ô'Ð'à!×'Ò'Ñ)Ô)€MØÐ,Ð,Ð,ÝÐaÐQ^ÐaÐaÐaÑbÔbÐbà-Ð-Ð-Ð-Ð-Ð-àÐÑÔ˜fÒ$Ð$ÝŒw�~Š~˜hÑ'Ô'ð 	>ÝÐ<°(Ð<Ð<Ñ=Ô=Ð=Ý!+Ô!7¸À)ÈWÐV^Ñ!_Ô!_Ñˆ�˜$™$åÑÔÐàˆ?Ý˜E‘l”lˆGà�YÒÐÝØkÈ)ÐkÐkÐbiÐkÐkñô ð ð ˆØˆØˆÝ#Ô4ˆð	Ý”˜°8Ð<Ñ<Ô<ð HÀ	ØÔ$Ô*ð JØ%.Ô%6Ô%<¸QÔ%?Ô%I�NØÔ$Ô*ð =Ý#4Ø!Ø!ØØ Ø!Ô)Ô/°Ô2Ø  !˜ñ$ô $�Lð !*Ô 1Ô 7¸Ô :Ô G�Ià Ð,Ý,1°)Ñ,<Ô,<˜˜[Ñ)àÔ$Ô*ð 	HÝ#4Ø!Ø!ØØ Ø!Ô)Ô/°Ô2Ø  !˜ñ$ô $�Lð )2Ô(9Ô(?ÀÔ(BÔ(G�D˜Ñ%ð5Hð Hð Hñ Hô Hð Hð Hð Hð Hð Hð Høøøð Hð Hð Hð Høøõ8 ð 	ð 	ð 	àˆDð	øøøð OÐNÀÐNÑNÔNˆØEÐE¸ÐEÑEÔEˆàð 	CÝ”o¥b¤h¨|Ñ&<Ô&<Ñ=Ô=ˆGˆGå”k ,µe´kÐBÑBÔBˆGàð 		?Ý”n \°1Ñ5Ô5ˆGÝ”o gÑ.Ô.ˆGØ˜5Ò Ð Ý¥¤
¨9¸¸NÑ8JÑ+KÑ LÔ LÑMÔM�	Ø�e E™lœlÒ*Ð*Ý!¥$¤)¨G°q¸>Ñ7IÑ,JÑ"KÔ"KÑLÔL�GÝ)¨'°<ÀÈGÑTÔTˆGˆGå”k &µ´Ð>Ñ>Ô>ˆGà˜ÒÐà—/’/ ! Q¨¨1Ñ-Ô-ˆà�G˜TÐ!Ð!s7   Ä+H& ÅCHÈH& ÈHÈH& È!HÈ"H& È&
H3È2H3c                 óH   — | j         d         j        j        }|€dS d|v rdS dS )Nr   Fs   LavcT)rS   r‹   rŒ   )r_   rŒ   s     r   Ú!_can_read_timestamps_from_packetsrÜ   ‰  s5   € ØÔ! !Ô$Ô2Ô<€IØÐØˆuØ�)ÐÐØˆtØˆ5r   c                 ó    — t          | ¦  «        r d„ |                      d¬¦  «        D ¦   «         S d„ |                      d¬¦  «        D ¦   «         S )Nc                 ó*   — g | ]}|j         ®	|j         ‘ŒS r   rx   ©rz   Úxs     r   r}   z,_decode_video_timestamps.<locals>.<listcomp>•  s!   € ÐMÐMÐM˜!¸1¼5Ð;L�”Ð;LÐ;LÐ;Lr   r   )rr   c                 ó*   — g | ]}|j         ®	|j         ‘ŒS r   rx   rß   s     r   r}   z,_decode_video_timestamps.<locals>.<listcomp>—  s!   € ÐNÐNÐN˜!¸A¼EÐ<M�”Ð<MÐ<MÐ<Mr   )rÜ   Údemuxr•   )r_   s    r   Ú_decode_video_timestampsrã   ’  sZ   € Ý(¨Ñ3Ô3ð OàMÐM˜yŸš°Q˜Ñ7Ô7ÐMÑMÔMÐMàNÐN˜y×/Ò/°aÐ/Ñ8Ô8ÐNÑNÔNÐNr   c                 ó&  ‡	— t           j                             ¦   «         s2t           j                             ¦   «         st	          t
          ¦  «         ddlm}  |¦   «         dk    rt          j	        | |¦  «        S t          ¦   «          d}g }	 t          j        | d¬¦  «        5 }|j        j        re|j        j        d         }|j        Š		 t!          |¦  «        }n'# t"          $ r t%          j        d| › �¦  «         Y nw xY wt)          |j        ¦  «        }ddd¦  «         n# 1 swxY w Y   n9# t"          $ r,}d| › d	|› �}t%          j        |t,          ¦  «         Y d}~nd}~ww xY w|                     ¦   «          |d
k    rˆ	fd„|D ¦   «         }||fS )ap  
    List the video frames timestamps.

    .. warning::

        In the near future, we intend to centralize PyTorch's video decoding
        capabilities within the `torchcodec
        <https://github.com/pytorch/torchcodec>`_ project. We encourage you to
        try it out and share your feedback, as the torchvision video decoders
        will eventually be deprecated.

    Note that the function decodes the whole video frame-by-frame.

    Args:
        filename (str): path to the video file
        pts_unit (str, optional): unit in which timestamp values will be returned
            either 'pts' or 'sec'. Defaults to 'pts'.

    Returns:
        pts (List[int] if pts_unit = 'pts', List[Fraction] if pts_unit = 'sec'):
            presentation timestamps for each one of the frames in the video.
        video_fps (float, optional): the frame rate for the video

    r   r¹   r»   Nr¼   r½   z Failed decoding frames for file zFailed to open container for z; Caught error: ro   c                 ó   •— g | ]}|‰z  ‘ŒS r   r   )rz   rà   Úvideo_time_bases     €r   r}   z)read_video_timestamps.<locals>.<listcomp>Ð  s   ø€ Ð0Ð0Ð0 qˆq�?Ñ"Ð0Ð0Ð0r   )rB   rC   rD   rE   r   Úread_video_timestampsrÈ   rº   r   Ú_read_video_timestampsr   r   rM   rS   rr   r†   rã   r“   rˆ   r‰   rJ   rÏ   ÚRuntimeWarningÚsort)
r   rl   rº   r¿   ry   r_   Úvideo_streamÚeÚmsgræ   s
            @r   rç   rç   š  s  ø€ õ2 Œ9×!Ò!Ñ#Ô#ð 3­E¬I×,@Ò,@Ñ,BÔ,Bð 3ÝÕ1Ñ2Ô2Ð2Ø-Ð-Ð-Ð-Ð-Ð-àÐÑÔ˜fÒ$Ð$ÝÔ0°¸8ÑDÔDÐDåÑÔÐà€IØ
€Cð+ÝŒW�X¨xÐ8Ñ8Ô8ð 	=¸IØÔ Ô&ð =Ø(Ô0Ô6°qÔ9�Ø".Ô"8�ðQÝ2°9Ñ=Ô=�C�CøÝ"ð Qð Qð QÝ”MÐ"OÀXÐ"OÐ"OÑPÔPÐPÐPÐPðQøøøå! ,Ô";Ñ<Ô<�	ð	=ð 	=ð 	=ñ 	=ô 	=ð 	=ð 	=ð 	=ð 	=ð 	=ð 	=øøøð 	=ð 	=ð 	=ð 	=øøõ ð +ð +ð +ØK¨hÐKÐKÈÐKÐKˆÝŒ�c�>Ñ*Ô*Ð*Ð*Ð*Ð*Ð*Ð*øøøøð+øøøð ‡H‚H�J„J€Jà�5ÒÐØ0Ð0Ð0Ð0¨CÐ0Ñ0Ô0ˆà�	ˆ>Ðs`   ÂD. Â$&D"ÃCÃD"Ã!C?Ã<D"Ã>C?Ã?D"ÄD. Ä"D&Ä&D. Ä)D&Ä*D. Ä.
E$Ä8"EÅE$)r   N)r   NNNNN)r   Nry   r²   rx   )1r�   r„   rÉ   rŽ   rˆ   Ú	fractionsr   Útypingr   r   r   r   r   r	   rI   rK   rB   Úutilsr   Ú r   r   ÚloggingÚ	set_levelÚERRORÚhasattrrr   rg   r\   ÚImportErrorr“   ÚAttributeErrorÚAVErrorr   Úboolr   r   r€   ÚstrÚTensorrJ   rF   rƒ   r¤   r±   rÅ   rÜ   rã   rç   r   r   r   ú<module>rü      s�  ðØ 	€	€	€	Ø €€€Ø 	€	€	€	Ø 	€	€	€	Ø €€€Ø Ð Ð Ð Ð Ð Ø :Ð :Ð :Ð :Ð :Ð :Ð :Ð :Ð :Ð :Ð :Ð :Ð :Ð :Ð :Ð :à Ð Ð Ð Ø €€€à 'Ð 'Ð 'Ð 'Ð 'Ð 'Ø Ð Ð Ð Ð Ð ðØ€I€I€Ià„J×Ò˜œÔ)Ñ*Ô*Ð*Øˆ7�2”8”>Ô,¨kÑ:Ô:ð 	
Øˆ[ðñ
ô 
ˆð!Ø”nˆˆøØð !ð !ð !Ø”jˆˆˆð!øøøøøàð ð ð Ø	ˆð	ñ
ô 
€B€B€Bðøøøðð ð ð ð
)�tð )ð )ð )ð )ð
 €ØÐ ð !Ø(,Ø*.Ø!%Ø!%Ø.2ðu"ð u"Øðu"à”ðu"ð 
ðu"ð ð	u"ð
 �d˜3 ˜8”nÔ%ðu"ð ˜%œ,Ô'ðu"ð ˜Œðu"ð ˜#”ðu"ð ˜D  c œNÔ+ðu"ð 
ðu"ð u"ð u"ð u"ðpMØ'ðMàðMð ðMð ð	Mð
 ðMð �c˜8 E¨#¨u°S¸#°X¬ÀÀSÄ	Ð*IÔ$JÔKÐKÔLðMð 
Ð
ÔðMð Mð Mð Mð`#ØŒ\ð#Ø)-Ð.>Ô)?ð#ØLOð#ØZ_ð#à
„\ð#ð #ð #ð #ð" )*Ø04ØØðv"ð v"Øðv"à�U˜H�_Ô%ðv"ð �e˜E 8˜OÔ,Ô-ðv"ð ð	v"ð
 ðv"ð ˆ5Œ<˜œ t¨C°¨H¤~Ð5Ô6ðv"ð v"ð v"ð v"ðrÐ1Ið Èdð ð ð ð ðOÐ(@ð OÀTÈ#ÄYð Oð Oð Oð Oð8ð 8 Cð 8°3ð 8À5ÈÈcÌÐT\Ð]bÔTcÐIcÔCdð 8ð 8ð 8ð 8ð 8ð 8s7   Á AB* ÂB ÂB* ÂB&Â#B* Â%B&Â&B* Â*B=Â<B=