
    Ch                     d   d Z ddlZddlZddlZddlmZ ej                  d        Zej                  d        Zej                  d        Zej                  d        Z	ej                  d        Z
ej                  d	        Zej                  d
        Zd Zd Zd Zej                  d        Zd Zy)zDecorators used by moviepy.    N)convert_to_secondsc                 >    |j                         } | |g|i | |S )zKApplies ``func(clip.copy(), *args, **kwargs)`` and returns ``clip.copy()``.)copyfuncclipargskwargsnew_clips        ]/var/www/html/Telegram-Engagement-Pod-/env/lib/python3.12/site-packages/moviepy/decorators.pyoutplacer      s&     yy{H#D#F#O    c                 R    |j                   r|j                         } | |g|i |S )zEIf the clip is a mask, convert it to RGB before running the function.)is_maskto_RGBr   r   r	   r
   s       r   convert_masks_to_RGBr      s+     ||{{}&t&v&&r   c                 n     | |g|i |}t        |dd      r | |j                  g|i ||_        |S )zZApplies the same function ``func`` to the mask of the clip created with
    ``func``.
    maskN)getattrr   r   s        r   apply_to_maskr      sC    
 D*4*6*Hx&X]]<T<V<Or   c                 n     | |g|i |}t        |dd      r | |j                  g|i ||_        |S )zMApplies the function ``func`` to the audio of the clip created with ``func``.audioN)r   r   r   s        r   apply_to_audior   &   sC     D*4*6*Hx$'hnn>t>v>Or   c                 H    |j                   t        d       | |g|i |S )z,Raises an error if the clip has no duration.zAttribute 'duration' not set)duration
ValueErrorr   s       r   requires_durationr   /   s/     }}788D*4*6**r   c                 `    t        |d      r|j                  t        d       | |g|i |S )z'Raises an error if the clip has no fps.fpszAttribute 'fps' not set)hasattrr    r   r   s       r   requires_fpsr"   8   s8     4488#3233D*4*6**r   c                     t        |d      r*|j                   | ||j                  g|i ||_        |S  | ||g|i |S )zUse an audio function on a video/audio clip.

    This decorator tells that the function func (audioclip -> audioclip)
    can be also used on a video clip, at which case it returns a
    videoclip with unmodified video and modified audio.
    r   )r!   r   )r   effectr   r	   r
   s        r   audio_video_effectr%   A   sP     tW::!fdjjB4B6BDJFD242622r   c                       fd}|S )zXApplies preprocess_func to variables in varnames before launching
    the function.
    c                 ~    t        j                  |       j                  fd}t        j                  | |      S )Nc                     t        |	      D cg c]  \  }}|v r
| 
|      n| }}}|j                         D ci c]  \  }}||v r 
|      n| }}} | |i |S c c}}w c c}}w )Nzipitems)r   r	   r
   argnamenew_argskwargvalue
new_kwargsargnamespreprocess_funcvarnamess            r   wrapperz/preprocess_args.<locals>.decor.<locals>.wrapperY   s     $'tX#6 $7KS$ (s $C( $7   '-lln&4NUE (1Bu-M&4   0Z00s   A%A+inspectgetfullargspecr	   	decoratordecorate)r   r5   r2   r3   r4   s     @r   decorzpreprocess_args.<locals>.decorV   s3    ))$/44	1 !!$00r    )r3   r4   r;   s   `` r   preprocess_argsr=   Q   s    
1( Lr   c                 "    t        t        |       S )z,Converts the specified variables to seconds.)r=   r   r4   s    r   convert_parameter_to_secondsr@   m   s    -x88r   c                 6    t        t        j                  |       S )z2Converts the specified variables to a path string.)r=   osfspathr?   s    r   convert_path_to_stringrD   r   s    299h//r   c                 R    |j                   |j                         } | |g|i |S )z(Add a mask to the clip if there is none.)r   	with_maskr   s       r   add_mask_if_nonerG   w   s/     yy~~&t&v&&r   c                      t        j                         j                  dd  fdfd}t        j                   |      S )zBWill use ``clip.fps`` if no ``fps=...`` is provided in **kwargs**.   Nc                 n    ||S t        | dd       r| j                  S t        dj                  z        )Nr    zNo 'fps' (frames per second) attribute specified for function %s and the clip has no 'fps' attribute. Either provide e.g. fps=24 in the arguments of the function, or define the clip's fps with `clip.fps=24`)r   r    AttributeError__name__)r   r    r   s     r   find_fpsz)use_clip_fps_by_default.<locals>.find_fps   sC    ?JT5$'88O1 48==A
 	
r   c           	          t        |
      D cg c]  \  }}|dk(  r	 ||      n| }}}|j                         D ci c]  \  }}||dk(  r	 ||      n| }	}} | |g|i |	S c c}}w c c}}w )Nr    r)   )r   r   r	   r
   r,   r-   r.   r/   r0   r1   r2   rM   s             r   r5   z(use_clip_fps_by_default.<locals>.wrapper   s      #42
2d $(5=HT3c92 	 
 #),,.
"0 EUN8D%(E"0 	 

 D282z22

s   A+A1r6   )r   r5   r2   rM   s   ` @@r   use_clip_fps_by_defaultrO      s?    %%d+004H


3 dG,,r   )__doc__r7   rB   r9   moviepy.toolsr   r   r   r   r   r   r"   r%   r=   r@   rD   rG   rO   r<   r   r   <module>rR      s    !  	  ,   ' '     + + + + 3 389
0
 ' '-r   