
    i                     H   d 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	d
 Z
d Zej                  d        Zej                  d        Zy)z)
all decorators used in moviepy go there
    N)cvsecsc                 >    |j                         } | |g|i | |S )z8 Applies f(clip.copy(), *a, **k) and returns clip.copy())copyfclipaknewclips        P/var/www/html/eduruby.in/venv/lib/python3.12/site-packages/moviepy/decorators.pyoutplacer   
   s&     iikGgQN    c                 R    |j                   r|j                         } | |g|i |S )zF If the clip is a mask, convert it to RGB before running the function )ismaskto_RGBr   r   r	   r
   s       r   convert_masks_to_RGBr      s+     {{{{}TAr   c                 n     | |g|i |}t        |dd      r | |j                  g|i ||_        |S )z^ This decorator will apply the same function f to the mask of
        the clip created with f maskN)getattrr   r   s        r   apply_to_maskr      sC    
 qAGw%//Q/Nr   c                 n     | |g|i |}t        |dd      r | |j                  g|i ||_        |S )zZ This decorator will apply the function f to the audio of
        the clip created with f audioN)r   r   r   s        r   apply_to_audior   $   sC    
 qAGw&'--1!1q1Nr   c                 H    |j                   t        d       | |g|i |S )z, Raise an error if the clip has no duration.zAttribute 'duration' not set)duration
ValueErrorr   s       r   requires_durationr   /   s/     }}788Qr   c                     t        |d      r9|j                         }|j                   | |j                  g|i ||_        |S  | |g|i |S )z Use an audio function on a video/audio clip
    
    This decorator tells that the function f (audioclip -> audioclip)
    can be also used on a video clip, at which case it returns a
    videoclip with unmodified video and modified audio.
    r   )hasattrr   r   r   s        r   audio_video_fxr!   :   sW     tW))+::!tzz3A33GMQr   c                 <      fd}t        j                   |      S )zD Applies fun to variables in varnames before launching the function c                 @   t        | d      r| j                  }n| j                  }|j                  }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	func_coder    r$   __code__co_varnameszipitems)r   r	   kwr$   namesargnamenew_ar
   vnew_kwfunvarnamess              r   wrapperz preprocess_args.<locals>.wrapperN   s    1k"I

I%%$'5M3 c4 #h.SS8 3 3 !hhj*a qH}SV!3 * *%"6""	3*s   B0B)	decorator)r1   r2   r3   s   `` r   preprocess_argsr5   K   s    # w''r   c                 "    t        t        |       S )z+Converts the specified variables to seconds)r5   r   )r2   s    r   convert_to_secondsr7   ]   s    68,,r   c                 R    |j                   |j                         } | |g|i |S )z* Add a mask to the clip if there is none. )r   add_maskr   s       r   add_mask_if_noner:   c   s.     yy}}TAr   c                 `     fd}t         d      r j                  }n j                  }|j                  dd }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 )z4 Will use clip.fps if no fps=... is provided in **k c                 n    | | S t        dd       rj                  S t        dj                  z        )NfpszNo '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   r1   z$use_clip_fps_by_default.<locals>.funp   sE    ?JT5$'88O 5 89zzB C 	Cr   r$      Nr=   r%   )r   r   r	   r
   r1   r$   r+   r,   r-   r.   r/   r0   s   ``          r   use_clip_fps_by_defaultrA   l   s    C q+KK	JJ	!!!"%E !$Au/#t +SXC/ /E / '')%!A 1e8Q* %F % T$E$V$$/%s   B$;B*)__doc__r4   moviepy.toolsr   r   r   r   r   r   r!   r5   r7   r:   rA    r   r   <module>rE      s                       ($-   % %r   