Ë
    Eü´jª  ã                   óF   — d Z ddlZddlmZ ddlmZ  G d„ d«      Z	 dd„Zy)	zW
On the long term this will implement several methods to make videos
out of VideoClips
é    N)ÚFFPLAY_BINARY)Úcross_platform_popen_paramsc                   ó.   — e Zd ZdZd„ Zd„ Zd„ Zd„ Zd„ Zy)ÚFFPLAY_VideoPreviewerae  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                 óê   — t         dddd|dd|d   |d   fz  d	d
|z  dg}t        t        j                  t        j                  t        j
                  dœ«      }t        j                  |fi |¤Ž| _        y )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         ú_/root/workspace/ytshorts/venv/lib/python3.12/site-packages/moviepy/video/io/ffplay_previewer.pyÚ__init__zFFPLAY_VideoPreviewer.__init__   s{   € ô ØØØØØØØ�t˜A‘w  Q¡Ð(Ñ(ØØ�c‰MØð
ˆô 3Ü—z‘z¬R¯Y©YÄÇÁÑIó
ˆô —H‘H˜SÑ1 LÑ1ˆ�	ó    c                 ó  — 	 | j                   j                  j                  |j                  «       «       y# t        $ rF}| j                   j                  «       \  }}|�|j                  «       }|› d|› �}t	        |«      ‚d}~ww xY w)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_framez FFPLAY_VideoPreviewer.show_frame8   s‡   € ð	!Ø�I‰I�O‰O×!Ñ! )×"3Ñ"3Ó"5Õ6øÜò 
	!Ø"Ÿi™i×3Ñ3Ó5‰OˆAˆ|ØÐ'Ø+×2Ñ2Ó4�ð �%ð )Ø)5¨ð8ð ô
 ˜%“.Ð ûð
	!ús   ‚36 ¶	B¿AB Â Bc                 ó  — | j                   r€| j                   j                  j                  «        | j                   j                  �$| j                   j                  j                  «        | j                   j	                  «        d| _         yy)z@Closes the writer, terminating the subprocess if is still alive.N)r   r   Úcloser   Úwait©r   s    r   r*   zFFPLAY_VideoPreviewer.closeH   s]   € à�9Š9Ø�I‰I�O‰O×!Ñ!Ô#Ø�y‰y×ÑÐ+Ø—	‘	× Ñ ×&Ñ&Ô(Ø�I‰I�N‰NÔàˆD�Ið r   c                 ó   — | S ©N© r,   s    r   Ú	__enter__zFFPLAY_VideoPreviewer.__enter__T   s   € Øˆr   c                 ó$   — | j                  «        y r.   )r*   )r   Úexc_typeÚ	exc_valueÚ	tracebacks       r   Ú__exit__zFFPLAY_VideoPreviewer.__exit__W   s   € Ø�
‰
�r   N)	Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r(   r*   r0   r5   r/   r   r   r   r      s    „ ñò 2ò6!ò òór   r   c                 ó  — t        | j                  ||«      5 }d}| j                  d|d¬«      D ]@  \  }}|j                  |«       |sŒd}|r|j	                  «        |sŒ1|j                  «        ŒB 	 ddd«       y# 1 sw Y   yxY w)a¨  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_videorG   [   sˆ   € ô@ 
˜tŸy™y¨#¨|Ó	<ð &À	ØˆØ×(Ñ(°D¸cÈÐ(ÓQò 	&‰HˆAˆuØ× Ñ  Ô'ò Ø#�áØ—N‘NÔ$âØ—O‘OÕ%ñ	&÷&÷ &ñ &ús   ˜0A<Á	A<Á A<Á<B)Úrgb24NN)	r9   Ú
subprocessr   Úmoviepy.configr   Úmoviepy.toolsr   r   rG   r/   r   r   ú<module>rL      s.   ðñó
 å (Ý 5÷Lñ Lð` BFô.&r   