
    dj                     t    d dl Z d dlmZ d dlmZ d dlmZ d dlm	Z	 e j
         G d de                      ZdS )    N)libav)Packet)avrational_to_fraction)
VideoFramec                       e Zd Zd Zd Zej        ddedz  fd            Zej        dde	dz  fd            Z
ed             Zed	             Zed
             Zed             Zed             ZdS )VideoStreamc                     | j         d| j         dt          |           ddS d| j         d| j         d| j        r| j        j        nd  d| j         j         d| j         j         dt          |           ddS )Nz<av.VideoStream #z video/<nocodec> at 0xx> z, z at 0x)codec_contextindexidnameformatwidthheightselfs    J/home/agentuser/manim-venv/lib/python3.11/site-packages/av/video/stream.py__repr__zVideoStream.__repr__
   s    %VtzVVDVVVVV>
 > >TY > >#';8t{D> >;?;M;S> >!(> >024=> > >	
    c                     |dv r(t          dt          |           j         d| d          | j        (t          dt          |           j         d| d          t	          | j        |          S )N)	frameraterate'z' object has no attribute ')AttributeErrortype__name__r   getattr)r   r   s     r   __getattr__zVideoStream.__getattr__   s    ((( KDJJ'KKDKKK   % KDJJ'KKDKKK   t)4000r   Nframec                 ~    | j                             |          }|D ]}| |_        | j        j        |j        _         |S )z
        Encode an :class:`.VideoFrame` and return a list of :class:`.Packet`.

        :rtype: list[Packet]

        .. seealso:: This is mostly a passthrough to :meth:`.CodecContext.encode`.
        )r   encode_streamptrr   stream_index)r   r"   packetspackets       r   r$   zVideoStream.encode   sF     $++E22 	5 	5F!FN&*hnFJ##r   r)   c                 6    | j                             |          S )z
        Decode a :class:`.Packet` and return a list of :class:`.VideoFrame`.

        :rtype: list[VideoFrame]

        .. seealso:: This is a passthrough to :meth:`.CodecContext.decode`.
        )r   decode)r   r)   s     r   r+   zVideoStream.decode/   s     !((000r   c                 X    t          t          j        | j        j                            S )z
        The average frame rate of this video stream.

        This is calculated when the file is opened by looking at the first
        few frames and averaging their rate.

        :type: fractions.Fraction | None
        )r   cythonaddressr&   avg_frame_rater   s    r   average_ratezVideoStream.average_rate:   s!     &fnTX5L&M&MNNNr   c                 X    t          t          j        | j        j                            S )a  
        The base frame rate of this stream.

        This is calculated as the lowest framerate at which the timestamps of
        frames can be represented accurately. See :ffmpeg:`AVStream.r_frame_rate`
        for more.

        :type: fractions.Fraction | None
        )r   r-   r.   r&   r_frame_rater   s    r   	base_ratezVideoStream.base_rateF   s!     &fnTX5J&K&KLLLr   c                     t          j        t          j        | j        t          j                  }t          t          j        |                    S )zThe guessed frame rate of this stream.

        This is a wrapper around :ffmpeg:`av_guess_frame_rate`, and uses multiple
        heuristics to decide what is "the" frame rate.

        :type: fractions.Fraction | None
        )libav_guess_frame_rater-   NULLr&   r   r.   )r   vals     r   guessed_ratezVideoStream.guessed_rateS   s=     "5K6;
 
 &fnS&9&9:::r   c                     t          j        | j        j        | j        t          j                  }t          t	          j        |                    S )a  The guessed sample aspect ratio (SAR) of this stream.

        This is a wrapper around :ffmpeg:`av_guess_sample_aspect_ratio`, and uses multiple
        heuristics to decide what is "the" sample aspect ratio.

        :type: fractions.Fraction | None
        )r5   av_guess_sample_aspect_ratio	containerr&   r-   r7   r   r.   )r   sars     r   sample_aspect_ratiozVideoStream.sample_aspect_ratioa   s@     ">N&+
 
 &fnS&9&9:::r   c                 h   t          j        t          j                  }t          j        t          j        |j                  t          j        |j                  | j        j	        | j
        j        z  | j        j        | j
        j        z  d           t          t          j        |                    S )zThe guessed display aspect ratio (DAR) of this stream.

        This is calculated from :meth:`.VideoStream.guessed_sample_aspect_ratio`.

        :type: fractions.Fraction | None
        i   )r-   declarer5   
AVRational	av_reducer.   numdenr   r   r>   r   r   )r   dars     r   display_aspect_ratioz VideoStream.display_aspect_ratioo   s     nS^,,N37##N37##K 8 <<K!9!==	
 	
 	
 &fnS&9&9:::r   )N)r   
__module____qualname__r   r!   r-   ccallr   r$   r   r+   propertyr0   r3   r9   r>   rF    r   r   r   r      s$       
 
 
	1 	1 	1 \ J-    \  \1 1Vd] 1 1 1 \1 	O 	O X	O 
M 
M X
M ; ; X; ; ; X; ; ; X; ; ;r   r   )r-   cython.cimportsr   r5   cython.cimports.av.packetr   cython.cimports.av.utilsr   cython.cimports.av.video.framer   cclassStreamr   rK   r   r   <module>rR      s     ( ( ( ( ( ( , , , , , , ; ; ; ; ; ; 5 5 5 5 5 5 w; w; w; w; w;& w; w; w; w; w;r   