
    W|h                     H    S r SSKrSSKJr  SSKJr   " S S5      r SS jrg)	zW
On the long term this will implement several methods to make videos
out of VideoClips
    N)FFPLAY_BINARY)cross_platform_popen_paramsc                   6    \ rS rSrSrS rS rS rS rS r	Sr
g	)
FFPLAY_VideoPreviewer   a=  A class for FFPLAY-based video preview.

Parameters
----------

size : tuple or list
  Size of the output video in pixels (width, height).

fps : int
  Frames per second in the output video file.

pixel_format : str
  Pixel format for the output video file, ``rgb24`` for normal video, ``rgba``
  if video with mask.
c                     [         SSSSUSSUS   US   4-  S	S
U-  S/n[        [        R                  [        R                  [        R
                  S.5      n[        R                  " U40 UD6U l        g )Nz	-autoexitz-frawvideoz-pixel_formatz-video_sizez%dx%dr      z
-frameratez%.02f-)stdoutstderrstdin)r   r   spDEVNULLSTDOUTPIPEPopenproc)selfsizefpspixel_formatcmdpopen_paramss         [/home/james-whalen/.local/lib/python3.13/site-packages/moviepy/video/io/ffplay_previewer.py__init__FFPLAY_VideoPreviewer.__init__   s{     tAwQ((cM
 3zzRYYI
 HHS1L1	    c                     U R                   R                  R                  UR                  5       5        g! [         aF  nU R                   R                  5       u  p4Ub  UR                  5       nU SU 3n[	        U5      eSnAff = f)zWrites one frame in the file.NzR

MoviePy error: FFPLAY encountered the following error while previewing clip :

 )r   r   writetobytesIOErrorcommunicatedecode)r   	img_arrayerr_ffplay_errorerrors         r   
show_frame FFPLAY_VideoPreviewer.show_frame8   s    	!IIOO!!)"3"3"56 
	!"ii335OA'+224 % ))58 
 %. 
	!s   36 
B ABBc                 (   U R                   (       a  U R                   R                  R                  5         U R                   R                  b$  U R                   R                  R                  5         U R                   R	                  5         SU l         gg)z@Closes the writer, terminating the subprocess if is still alive.N)r   r   closer   waitr   s    r   r-   FFPLAY_VideoPreviewer.closeH   s]    99IIOO!!#yy+		  &&(IINNDI r   c                     U $ N r/   s    r   	__enter__FFPLAY_VideoPreviewer.__enter__T   s    r   c                 $    U R                  5         g r2   )r-   )r   exc_type	exc_value	tracebacks       r   __exit__FFPLAY_VideoPreviewer.__exit__W   s    

r   )r   N)__name__
__module____qualname____firstlineno____doc__r   r*   r-   r4   r:   __static_attributes__r3   r   r   r   r      s      26! r   r   c                 4   [        U R                  X5       nSnU R                  SUSS9 HQ  u  pxUR                  U5        U(       d  M  SnU(       a  UR	                  5         U(       d  MA  UR                  5         MS     SSS5        g! , (       d  f       g= f)aT  Preview the clip using ffplay. See VideoClip.preview for details
on the parameters.

Parameters
----------

clip : VideoClip
  The clip to preview

fps : int
  Number of frames per seconds in the displayed video.

pixel_format : str, optional
  Warning: This is not used anywhere in the code and should probably
  be removed.
  It is believed pixel format rgb24 does not work properly for now because
  it requires applying a mask on CompositeVideoClip and that is believed to
  not be working.

  Pixel format for the output video file, ``rgb24`` for normal video, ``rgba``
  if video with mask

audio_flag : Thread.Event, optional
  A thread event that video will wait for. If not provided we ignore audio

video_flag : Thread.Event, optional
  A thread event that video will set after first frame has been shown. If not
  provided, we simply ignore
Tuint8)
with_timesr   dtypeFN)r   r   iter_framesr*   setr.   )	clipr   r   
audio_flag
video_flag	previewerfirst_frametframes	            r   ffplay_preview_videorO   [   s{    @ 
tyy#	<	((Dc(QHA  ' {#NN$:OO% R 
=	<	<s   /B	
B	,B		
B)rgb24NN)	r@   
subprocessr   moviepy.configr   moviepy.toolsr   r   rO   r3   r   r   <module>rT      s.   
  ( 5L L` BF.&r   