
    ~Zi\1                     Z   S SK Jr  S SKJr  SSKJr  SSKJrJr  S SK	J
r
  S SKrS rS	 r " S
 S\
5      rS rS rS r " S S\5      r " S S\5      r " S S\5      r " S S\5      r " S S\5      r " S S\5      r " S S\5      r " S S\5      r\1S4S jrS"S  jrS"S! jrS/rg)#    )unicode_literals)
basestring   )KwargReprNode)escape_charsget_hash_int)objectNc                 F    SnU H  n[        X5      (       d  M  Sn  U$    U$ )NFT)
isinstance)objtypesvalidstream_types       f/var/www/eduai.edurigo.com/question_generate/ques_gen_env/lib/python3.13/site-packages/ffmpeg/nodes.py_is_of_typesr   
   s0    Ec''EL	  L    c           	          SR                  U  Vs/ s H)  nSR                  UR                  UR                  5      PM+     sn5      $ s  snf )Nz, z{}.{})joinformat
__module____name__)r   xs     r   _get_types_strr      s6    99N1gnnQ\\1::>NOONs   0Ac                   \    \ rS rSrSr SS jrS rS rS rS r	\
S	 5       r\
S
 5       rSrg)Stream   z^Represents the outgoing edge of an upstream node; may be used to create more downstream nodes.Nc                     [        X5      (       d-  [        SR                  [        U5      [	        U5      5      5      eXl        X l        X@l        g )NzHExpected upstream node to be of one of the following type(s): {}; got {})r   	TypeErrorr   r   typenodelabelselector)selfupstream_nodeupstream_label
node_typesupstream_selectors        r   __init__Stream.__init__   sJ     M66Zaa":.]0C 
 "	#
)r   c                 h    [        [        U R                  5      [        U R                  5      /5      $ N)r   hashr    r!   r#   s    r   __hash__Stream.__hash__'   s#    T$))_d4::.>?@@r   c                 0    [        U 5      [        U5      :H  $ r+   )r,   )r#   others     r   __eq__Stream.__eq__*   s    DzT%[((r   c                     U R                   R                  SS9nSnU R                  (       a  SR                  U R                  5      nSR                  XR                  X R                   R
                  5      nU$ )NF)include_hash z:{}z{}[{!r}{}] <{}>)r    	long_reprr"   r   r!   
short_hash)r#   	node_reprr"   outs       r   __repr__Stream.__repr__-   sa    II''U';	==||DMM2H&&zz8YY-A-A
 
r   c                     U R                   b  [        SR                  U 5      5      e[        U[        5      (       d  [        SR                  U5      5      eU R                  R                  U R                  US9$ )aA  
Select a component (audio, video) of the stream.

Example:
    Process the audio and video portions of a stream independently::

        input = ffmpeg.input('in.mp4')
        audio = input['a'].filter("aecho", 0.8, 0.9, 1000, 0.3)
        video = input['v'].hflip()
        out = ffmpeg.output(audio, video, 'out.mp4')
z!Stream already has a selector: {}z*Expected string index (e.g. 'a'); got {!r}r!   r"   )	r"   
ValueErrorr   r   r   r   r    streamr!   )r#   indexs     r   __getitem__Stream.__getitem__7   sh     ==$@GGMNNE:..HOOPUVWWyydjj5AAr   c                     U S   $ )aJ  Select the audio-portion of a stream.

Some ffmpeg filters drop audio streams, and care must be taken
to preserve the audio in the final output.  The ``.audio`` and
``.video`` operators can be used to reference the audio/video
portions of a stream so that they can be processed separately
and then re-combined later in the pipeline.  This dilemma is
intrinsic to ffmpeg, and ffmpeg-python tries to stay out of the
way while users may refer to the official ffmpeg documentation
as to why certain filters drop audio.

``stream.audio`` is a shorthand for ``stream['a']``.

Example:
    Process the audio and video portions of a stream independently::

        input = ffmpeg.input('in.mp4')
        audio = input.audio.filter("aecho", 0.8, 0.9, 1000, 0.3)
        video = input.video.hflip()
        out = ffmpeg.output(audio, video, 'out.mp4')
a r-   s    r   audioStream.audioI       . Cyr   c                     U S   $ )aJ  Select the video-portion of a stream.

Some ffmpeg filters drop audio streams, and care must be taken
to preserve the audio in the final output.  The ``.audio`` and
``.video`` operators can be used to reference the audio/video
portions of a stream so that they can be processed separately
and then re-combined later in the pipeline.  This dilemma is
intrinsic to ffmpeg, and ffmpeg-python tries to stay out of the
way while users may refer to the official ffmpeg documentation
as to why certain filters drop audio.

``stream.video`` is a shorthand for ``stream['v']``.

Example:
    Process the audio and video portions of a stream independently::

        input = ffmpeg.input('in.mp4')
        audio = input.audio.filter("aecho", 0.8, 0.9, 1000, 0.3)
        video = input.video.hflip()
        out = ffmpeg.output(audio, video, 'out.mp4')
vrF   r-   s    r   videoStream.videob   rI   r   )r!   r    r"   r+   )r   r   __qualname____firstlineno____doc__r(   r.   r2   r;   rB   propertyrG   rL   __static_attributes__rF   r   r   r   r      sO    h LP*A)B$  0  r   r   c                     U c  0 nU$ [        U [        5      (       a  S U 0nU$ [        U [        [        45      (       a  [	        [        U 5      5      nU$ [        U [        5      (       a  U nW$ r+   )r   r   listtupledict	enumeratestream_spec
stream_maps     r   get_stream_mapr[   |   sz    
  
K	(	(K(

 	 
K$	/	/)K01
  
K	&	& 
r   c                     / n[        U R                  5       5       HV  n[        U[        5      (       d#  [	        SR                  [        U5      5      5      eUR                  UR                  5        MX     U$ )NzExpected Stream; got {})	rT   valuesr   r   r   r   r   appendr    )rZ   nodesr@   s      r   get_stream_map_nodesr`      s^    Ez((*+&&))5<<T&\JKKV[[! , Lr   c                 .    [        U 5      n[        U5      $ r+   )r[   r`   rX   s     r   get_stream_spec_nodesrb      s    ,J
++r   c                   t   ^  \ rS rSrSr\S 5       r\S 5       r\S 5       r/ 0 4U 4S jjr	S
S jr
S rS	rU =r$ )Node   z	Node basec                     Ub3  [        U5      U:  a$  [        SR                  U[        U5      5      5      eUb4  [        U5      U:  a$  [        SR                  U[        U5      5      5      eg g )Nz,Expected at least {} input stream(s); got {}z+Expected at most {} input stream(s); got {})lenr?   r   )clsrZ   
min_inputs
max_inputss       r   __check_input_lenNode.__check_input_len   sw    !c*o
&B>EEJ 
 #J*(D=DDJ  )E#r   c           	          [        UR                  5       5       H@  n[        X25      (       a  M  [        SR	                  [        U5      [        U5      5      5      e   g )NzKExpected incoming stream(s) to be of one of the following types: {}; got {})rT   r]   r   r   r   r   r   )rh   rZ   incoming_stream_typesr@   s       r   __check_input_typesNode.__check_input_types   sO    :,,./F>>ahh&'<=tF|  0r   c                     0 n[        UR                  5       5       H*  u  p4UR                  UR                  UR                  4X#'   M,     U$ r+   )rT   itemsr    r!   r"   )rh   rZ   incoming_edge_mapdownstream_labelupstreams        r   __get_incoming_edge_mapNode.__get_incoming_edge_map   sO    *.z/?/?/A*B&!!3/ +C ! r   c	                    > [        U5      n	U R                  XU5        U R                  X5        U R                  U	5      n
[        [
        U ]  XXx5        X@l        X0l        g r+   )	r[   _Node__check_input_len_Node__check_input_types_Node__get_incoming_edge_mapsuperrd   r(   _Node__outgoing_stream_type_Node__incoming_stream_types)r#   rY   namern   outgoing_stream_typeri   rj   argskwargsrZ   rs   	__class__s              r   r(   Node.__init__   s\     $K0
zzB  C 88DdD"#4DI&:#'<$r   c                 "    U R                  XUS9$ )zlCreate an outgoing stream originating from this node.

More nodes may be attached onto the outgoing stream.
r'   )r}   )r#   r!   r"   s      r   r@   Node.stream   s    
 **4(*SSr   c                     [        U[        5      (       a$  U R                  UR                  UR                  S9$ U R                  US9$ )a"  Create an outgoing stream originating from this node; syntactic sugar for ``self.stream(label)``.
It can also be used to apply a selector: e.g. ``node[0:'a']`` returns a stream with label 0 and
selector ``'a'``, which is the same as ``node.stream(label=0, selector='a')``.

Example:
    Process the audio and video portions of a stream independently::

        input = ffmpeg.input('in.mp4')
        audio = input[:'a'].filter("aecho", 0.8, 0.9, 1000, 0.3)
        video = input[:'v'].hflip()
        out = ffmpeg.output(audio, video, 'out.mp4')
r>   )r!   )r   slicer@   startstop)r#   items     r   rB   Node.__getitem__   s=     dE"";;TZZ$));DD;;T;**r   )__incoming_stream_types__outgoing_stream_type)NN)r   r   rN   rO   rP   classmethodry   rz   r{   r(   r@   rB   rR   __classcell__r   s   @r   rd   rd      s]        ! !$ =(T+ +r   rd   c                   ,   ^  \ rS rSrSU 4S jjrSrU =r$ )FilterableStream   c                 D   > [         [        U ]  X[        [        1U5        g r+   )r|   r   r(   	InputNode
FilterNoder#   r$   r%   r'   r   s       r   r(   FilterableStream.__init__   s     .Iz+BDU	
r   rF   r+   r   r   rN   rO   r(   rR   r   r   s   @r   r   r      s    
 
r   r   c                   D   ^  \ rS rSrSr/ 0 4U 4S jjr\S 5       rSrU =r	$ )r      zInputNode typec                 >   > [         [        U ]  S U0 [        SSUUS9  g )Nr   rY   r   rn   r   ri   rj   r   r   )r|   r   r(   r   )r#   r   r   r   r   s       r   r(   InputNode.__init__   s/    i'"$!1 	( 		
r   c                 Z    [         R                  R                  U R                  S   5      $ Nfilenameospathbasenamer   r-   s    r   
short_reprInputNode.short_repr       wwJ 788r   rF   )
r   r   rN   rO   rP   r(   rQ   r   rR   r   r   s   @r   r   r      s$    "$R 

 9 9r   r   c                   :   ^  \ rS rSrS/ 0 4U 4S jjr S rSrU =r$ )r   i  r   c                 H   > [         [        U ]  UU[        1[        SUUUS9  g Nr   r   )r|   r   r(   r   )r#   rY   r   rj   r   r   r   s         r   r(   FilterNode.__init__	  s2    j$(##3"4!1! 	) 		
r   c                 r   U R                   nU R                  nU R                  S;   a  [        U5      /nU Vs/ s H  n[	        US5      PM     nn0 n[        UR                  5       5       H!  u  px[	        US5      n[	        US5      nXU'   M#     U Vs/ s H  n[	        US5      PM     n	n[        U5       Vs/ s H  nSR                  XvU   5      PM     n
nX-   n[	        U R                  S5      nU(       a#  USR                  SR                  U5      5      -  n[	        US5      $ s  snf s  snf s  snf )N)splitasplitz\'=:z{}={}z={}:z\'[],;)
r   r   r   rg   r   rT   rr   sortedr   r   )r#   outgoing_edgesr   r   r   out_args
out_kwargskrK   
arg_paramskwarg_paramsparamsparams_texts                r   _get_filterFilterNode._get_filter  s   yy99++'(D7;<t!LH-t<
(DAQ)AQ)AqM )
 :BBAl1h/
BBHBTUBTQqQ-8BTU*"499h75<<(899KK44 = CUs   D*D/:D4rF   )r   r   rN   rO   r(   r   rR   r   r   s   @r   r   r     s    56R 

 5 5r   r   c                   @   ^  \ rS rSr/ 0 4U 4S jjr\S 5       rSrU =r$ )
OutputNodei0  c                 H   > [         [        U ]  UU[        1[        SS UUS9  g r   )r|   r   r(   r   OutputStreamr#   r@   r   r   r   r   s        r   r(   OutputNode.__init__1  s2    j$(#3"4!- 	) 		
r   c                 Z    [         R                  R                  U R                  S   5      $ r   r   r-   s    r   r   OutputNode.short_repr=  r   r   rF   )	r   r   rN   rO   r(   rQ   r   rR   r   r   s   @r   r   r   0  s!    *,R 

 9 9r   r   c                   ,   ^  \ rS rSrSU 4S jjrSrU =r$ )r   iB  c                 L   > [         [        U ]  UU[        [        [
        1US9  g )Nr   )r|   r   r(   r   
GlobalNodeMergeOutputsNoder   s       r   r(   OutputStream.__init__C  s+    lD*%56/	 	+ 	
r   rF   r+   r   r   s   @r   r   r   B  s    
 
r   r   c                   (   ^  \ rS rSrU 4S jrSrU =r$ )r   iM  c           	      D   > [         [        U ]  UU[        1[        SS S9  g )Nr   )rY   r   rn   r   ri   rj   )r|   r   r(   r   )r#   streamsr   r   s      r   r(   MergeOutputsNode.__init__N  s,    .#/.!- 	/ 	
r   rF   r   r   s   @r   r   r   M  s    
 
r   r   c                   0   ^  \ rS rSr/ 0 4U 4S jjrSrU =r$ )r   iZ  c                 H   > [         [        U ]  UU[        1[        SSUUS9  g r   )r|   r   r(   r   r   s        r   r(   GlobalNode.__init__[  s1    j$(#/.!- 	) 		
r   rF   r   r   s   @r   r   r   Z  s    *,R 

 

r   r   c                    ^ ^ UU 4S jnU$ )Nc                 t   > T=(       d    U R                   nT Vs/ s H  n[        X!U 5      PM       nU $ s  snf r+   )r   setattr)func	func_namestream_classr   stream_classess      r   	decorator"stream_operator.<locals>.decoratori  s5    )DMM	DRSNL$	/NS 	Ts   5rF   )r   r   r   s   `` r   stream_operatorr   h  s    
 r   c                      [        [        1U S9$ N)r   r   )r   r   r   s    r   filter_operatorr   q  s    +;*<4HHr   c                      [        [        1U S9$ r   )r   r   r   s    r   output_operatorr   u  s    <.tDDr   r+   )
__future__r   past.builtinsr   dagr   _utilsr   r   builtinsr	   r   r   r   r   r[   r`   rb   rd   r   r   r   r   r   r   r   r   r   r   __all__rF   r   r   <module>r      s    ' $  .  	PbV bJ	,
R+= R+j
v 
9 9*$5 $5P9 9$
6 
	
t 	

 
 %+8$ IE *r   