
    i                         d dl Z d dlZd dlZd dlZd dlmZmZ d dl	m
Z
  ej                          ej                  j                  d       ddZed	d       Zee	 	 d
d              Zy)    N)convert_masks_to_RGBrequires_duration)cvsecsMoviePyc                 *   t         j                  j                  | j                  dd            }|2t         j                  j                  | j                  dd ddd         }|j                  |d       t         j                  j                          y)z:Splashes the given image array on the given pygame screen r      N   r   r   )	pg	surfarraymake_surfaceswapaxesdisplayset_modeshapeblitflip)imarrayscreenas      V/var/www/html/eduruby.in/venv/lib/python3.12/site-packages/moviepy/video/io/preview.py	imdisplayr      sl    
!!'"2"21a"89A~$$W]]2A%6tt%<=
KK6JJOO    c           	         t        |t              rt        | }|r9| j                  -ddlmc mc m} |j                  | j                  d      g      } | j                  |      }t        |       |rg }	 t        j                  j                         D ]  }|j                  t        j                  k(  r-|j                   t        j"                  k(  s>t%        d       |c S |j                  t        j&                  k(  skt        j(                  j+                         \  }}	||	|f   }
|j-                  ||	f|
d       t%        dt/        ||	f      dt/        |
              t1        j2                  d       y)	a  
    Splashes the frame of clip corresponding to time ``t``.
    
    Parameters
    ------------
    
    t
      Time in seconds of the frame to display.
    
    with_mask
      ``False`` if the clip has a mask but you want to see the clip
      without the mask.
    
    Nr   r   zKeyboard interrupt)positioncolorzposition, color : z, gQ?)
isinstancetupler   mask,moviepy.video.compositing.CompositeVideoClipvideocompositingCompositeVideoClipset_position	get_framer   r   eventgettypeKEYDOWNkeyK_ESCAPEprintMOUSEBUTTONDOWNmouseget_posappendstrtimesleep)clipt	with_maskinteractivecvcimgresultr'   xyrgbs              r   showr?      s0   " !UAJdii+BB%%t'8'8'@&AB
..
CcN 
3::+yyBKK/23%ZZ2#5#5588++-DAqad)CMM1v"DE.1v;C12 3
3 JJsO  r   c                 v   |rt         j                  }nd}t         j                  j                  | j                  |      }|xr | j
                  du}|rht        j                         }	t        j                         }
t        j                  | j
                  j                  ||||
|	f      }|j                          | j                  d      }t        ||       |r 	j                          
j                          g }t        j                         }t!        j"                  d|z  | j$                  dz
  d|z        D ]{  }| j                  |      }t         j&                  j)                         D ]   }|j*                  t         j,                  k(  s:|j*                  t         j.                  k(  r@|j0                  t         j2                  k(  r#|r	j5                          t7        d       |c c S |j*                  t         j8                  k(  st         j:                  j=                         \  }}|||f   }|j?                  |||f|d       t7        dd	|tA        ||f      tA        |      fz          t        j                         }t        jB                  tE        d|||z
  z
               t        ||       ~ y)
a   
    Displays the clip in a window, at the given frames per second
    (of movie) rate. It will avoid that the clip be played faster
    than normal, but it cannot avoid the clip to be played slower
    than normal if the computations are complex. In this case, try
    reducing the ``fps``.
    
    Parameters
    ------------
    
    fps
      Number of frames per seconds in the displayed video.
        
    audio
      ``True`` (default) if you want the clip's audio be played during
      the preview.
        
    audio_fps
      The frames per second to use when generating the audio sound.
      
    fullscreen
      ``True`` if you want the preview to be displayed fullscreen.
      
    r   N)targetargsg      ?gMbP?	Interrupt)r3   r   r   ztime, position, color : z%.03f, %s, %s)#r   
FULLSCREENr   r   sizeaudio	threadingEventThreadpreviewstartr&   r   setwaitr3   nparangedurationr'   r(   r)   QUITr*   r+   r,   clearr-   r.   r/   r0   r1   r2   r4   max)r5   fpsrF   	audio_fpsaudio_buffersizeaudio_nbytes
fullscreenflagsr   	videoFlag	audioFlagaudiothreadr:   r;   t0r6   r'   r<   r=   r>   t1s                        r   rJ   rJ   B   s&   8  ZZ  E2F.tzz-E OO%	OO%	&&djj.@.@-6-=-9-6	-CD
 	
..
Cc6F	BYYsSy$--"4cCi@ nnQXX\\^ 	2EzzRWW$ZZ2::-%))r{{2JOO%k"r111xx'')1!Q$iqq!f(+- .0/#q!f+s3x031 2	2  YY[

3q!r"u+&'#v-r   )N)r   TF)   Ti"V  i  r	   F)rG   r3   numpyrN   pygamer   moviepy.decoratorsr   r   moviepy.toolsr   initr   set_captionr   r?   rJ    r   r   <module>rg      sr        F   	 

  y ! ' 'T HL',S  Sr   