
    m i                     x    d dl Z d dlmZ d dlmZ d dlmZmZ d dl	m
Z
 e j         G d de                      ZdS )    N)libav)Packet)avrational_to_fractionto_avrational)
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                     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, xz at 0x>)indexnameformatcodec_contextwidthheightidselfs    O/var/www/html/auto_sub_bot/venv/lib/python3.11/site-packages/av/video/stream.py__repr__zVideoStream.__repr__
   s    >
 > >TY > >#';8t{D> >;?;M;S> >!(> >024=> > >	
    c                     |dv r(t          dt          |           j         d| d          t          | j        |          S )N)	frameraterate'z' object has no attribute ')AttributeErrortype__name__getattrr   )r   r   s     r   __getattr__zVideoStream.__getattr__   sT    ((( 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_rate5   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_rateA   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_rateN   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
        )r6   av_guess_sample_aspect_ratio	containerr'   r.   r8   r   r/   )r   sars     r   sample_aspect_ratiozVideoStream.sample_aspect_ratio\   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.   declarer6   
AVRational	av_reducer/   numdenr   r   r?   r   r   )r   dars     r   display_aspect_ratioz VideoStream.display_aspect_ratioj   s     nS^,,N37##N37##K 8 <<K!9!==	
 	
 	
 &fnS&9&9:::r   )N)r    
__module____qualname__r   r"   r.   ccallr   r%   r   r,   propertyr1   r4   r:   r?   rG    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   r6   cython.cimports.av.packetr   cython.cimports.av.utilsr   r   cython.cimports.av.video.framer   cclassStreamr	   rL   r   r   <module>rS      s     ( ( ( ( ( ( , , , , , , J J J J J J J J 5 5 5 5 5 5 r; r; r; r; r;& r; r; r; r; r;r   