o
    Y+i  ã                   @   sœ   d Z ddlZddlmZ ejdd„ ƒZejdd„ ƒZejdd	„ ƒZejd
d„ ƒZejdd„ ƒZejdd„ ƒZ	dd„ Z
dd„ Zejdd„ ƒZejdd„ ƒZdS )z)
all decorators used in moviepy go there
é    N)Úcvsecsc                 O   s"   |  ¡ }| |g|¢R i |¤Ž |S )z8 Applies f(clip.copy(), *a, **k) and returns clip.copy())Úcopy©ÚfÚclipÚaÚkÚnewclip© r
   úE/var/www/html/venv/lib/python3.10/site-packages/moviepy/decorators.pyÚoutplace
   s   r   c                 O   s$   |j r| ¡ }| |g|¢R i |¤ŽS )zF If the clip is a mask, convert it to RGB before running the function )ÚismaskÚto_RGB©r   r   r   r   r
   r
   r   Úconvert_masks_to_RGB   s   r   c                 O   ó@   | |g|¢R i |¤Ž}t |ddƒr| |jg|¢R i |¤Ž|_|S )z^ This decorator will apply the same function f to the mask of
        the clip created with f ÚmaskN)Úgetattrr   r   r
   r
   r   Úapply_to_mask   ó   r   c                 O   r   )zZ This decorator will apply the function f to the audio of
        the clip created with f ÚaudioN)r   r   r   r
   r
   r   Úapply_to_audio$   r   r   c                 O   s(   |j du r	tdƒ‚| |g|¢R i |¤ŽS )z, Raise an error if the clip has no duration.NzAttribute 'duration' not set)ÚdurationÚ
ValueErrorr   r
   r
   r   Úrequires_duration/   s   
r   c                 O   sP   t |dƒr| ¡ }|jdur| |jg|¢R i |¤Ž|_|S | |g|¢R 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   N)Úhasattrr   r   r   r
   r
   r   Úaudio_video_fx:   s   
	
r   c                    s   ‡ ‡fdd„}t   |¡S )zD Applies fun to variables in varnames before launching the function c                    s^   t | dƒr	| j}n| j}|j}‡ ‡fdd„t||ƒD ƒ}‡ ‡fdd„| ¡ D ƒ}| |i |¤ŽS )NÚ	func_codec                    s$   g | ]\}}|ˆv rˆ |ƒn|‘qS r
   r
   ©Ú.0ÚargÚname©ÚfunÚvarnamesr
   r   Ú
<listcomp>U   ó    ÿz4preprocess_args.<locals>.wrapper.<locals>.<listcomp>c                    s&   i | ]\}}||ˆv rˆ |ƒn|“qS r
   r
   ©r   r   Úvr"   r
   r   Ú
<dictcomp>W   ó    ÿz4preprocess_args.<locals>.wrapper.<locals>.<dictcomp>©r   r   Ú__code__Úco_varnamesÚzipÚitems)r   r   Úkwr   ÚnamesÚnew_aÚnew_kwr"   r
   r   ÚwrapperN   s   
ÿÿz preprocess_args.<locals>.wrapper)Ú	decorator)r#   r$   r4   r
   r"   r   Úpreprocess_argsK   s   
r6   c                 C   s
   t t| ƒS )z+Converts the specified variables to seconds)r6   r   )r$   r
   r
   r   Úconvert_to_seconds]   s   
r7   c                 O   s(   |j du r	| ¡ }| |g|¢R i |¤ŽS )z* Add a mask to the clip if there is none. N)r   Úadd_maskr   r
   r
   r   Úadd_mask_if_nonec   s   
r9   c                    sx   ‡ ‡fdd„‰t ˆdƒrˆj}nˆj}|jdd… }‡fdd„t||ƒD ƒ}‡fdd	„| ¡ D ƒ}ˆˆ g|¢R i |¤ŽS )
z4 Will use clip.fps if no fps=... is provided in **k c                    s,   | d ur| S t ˆ dd ƒrˆ jS tdˆj ƒ‚)NÚfpszÎNo '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   r
   r   r#   p   s   ýz$use_clip_fps_by_default.<locals>.funr   é   Nc                    s$   g | ]\}}|d krˆ |ƒn|‘qS r=   r
   r   ©r#   r
   r   r%   ‚   r&   z+use_clip_fps_by_default.<locals>.<listcomp>c                    s&   i | ]\}}||d krˆ |ƒn|“qS r=   r
   r'   r?   r
   r   r)   „   r*   z+use_clip_fps_by_default.<locals>.<dictcomp>r+   )r   r   r   r   r   r1   r2   r3   r
   )r   r   r#   r   Úuse_clip_fps_by_defaultl   s   

ÿ
ÿr@   )Ú__doc__r5   Úmoviepy.toolsr   r   r   r   r   r   r   r6   r7   r9   r@   r
   r
   r
   r   Ú<module>   s*    








