Ë
    Eü´jõ  ã                   óF   — d Z ddlZddlZddlmZ ddlmZ  G d„ de«      Zy)zXImplements ImageSequenceClip, a class to create a video clip from a set
of image files.
é    N)Úimread)Ú	VideoClipc                   ó"   — e Zd ZdZ	 	 	 	 	 dd„Zy)ÚImageSequenceClipa   A VideoClip made from a series of images.

    Parameters
    ----------

    sequence
      Can be one of these:

      - The name of a folder (containing only pictures). The pictures
        will be considered in alphanumerical order.
      - A list of names of image files. In this case you can choose to
        load the pictures in memory pictures
      - A list of Numpy arrays representing images. In this last case,
        masks are not supported currently.

    fps
      Number of picture frames to read per second. Instead, you can provide
      the duration of each image with durations (see below)

    durations
      List of the duration of each picture.

    with_mask
      Should the alpha layer of PNG images be considered as a mask ?

    is_mask
      Will this sequence of pictures be used as an animated mask.

    load_images
      Specify that all images should be loaded into the RAM. This is only
      interesting if you have a small number of images that will be used
      more than once.
    Nc           	      ó$  ‡ ‡— |€|€t        d«      ‚t        j                  ‰ |¬«       d}t        |t        «      r6t        |d   t
        «      r |r|D �cg c]  }t        |«      ‘Œ }}d}nRd}nOd}nLd}t        t        j                  |«      D �cg c]"  }t        j                  j                  ||«      ‘Œ$ c}«      }t        |d   t
        «      rt        |d   «      j                  }	n|d   j                  }	|D ]9  }
|
}t        |
t
        «      rt        |
«      }|	|j                  k7  sŒ0t        d«      ‚ |‰ _        |�n|D �
cg c]  }
d|z  ‘Œ	 }}
t        t!        |«      «      D �cg c]8  }d|z  |z  t#        j$                  t"        j&                  «      j(                  z
  ‘Œ: c}‰ _        n'dgt	        t#        j,                  |«      «      z   ‰ _        |‰ _        t1        |«      ‰ _        ‰ j2                  ‰ _        |‰ _        |€t!        |«      ‰ j2                  z  ‰ _        ˆ fd„Š|r´d ‰ _        d ‰ _        ˆˆ fd	„}|�rt        ‰ j6                  d   «      j                  d
   dk(  rît        d¬«      ‰ _        d ‰ j<                  _        d ‰ j<                  _        ˆˆ fd„}|‰ j<                  _         |d«      j                  d d
 d d d…   ‰ j<                  _         nyˆˆ fd„}|rq‰ j6                  d   j                  d
   dk(  rRt        d¬«      ‰ _        ˆˆ fd„}|‰ j<                  _         |d«      j                  d d
 d d d…   ‰ j<                  _         |‰ _         |d«      j                  d d
 d d d…   ‰ _         y c c}w c c}w c c}
w c c}w )Nz+Please provide either 'fps' or 'durations'.)Úis_maskTr   FzBMoviePy: ImageSequenceClip requires all images to be the same sizeç      ð?c                 óž   •— t        t        t        ‰j                  «      «      D �cg c]  }‰j                  |   | k  sŒ|‘Œ c}«      S c c}w )N)ÚmaxÚrangeÚlenÚsequenceÚimages_starts)ÚtÚiÚselfs     €ú`/root/workspace/ytshorts/venv/lib/python3.12/site-packages/moviepy/video/io/ImageSequenceClip.pyÚfind_image_indexz4ImageSequenceClip.__init__.<locals>.find_image_indexs   sB   ø€ ÜÜ!¤# d§m¡mÓ"4Ó5ÖT�q¸×9KÑ9KÈAÑ9NÐRSÓ9S’ÒTóð ùÚTs
   §A
¿A
c                 óª   •—  ‰| «      }|‰j                   k7  r0t        ‰j                  |   «      d d …d d …d d…f   ‰_        |‰_         ‰j                  S ©Né   )Ú
last_indexr   r   Ú
last_image©r   Úindexr   r   s     €€r   Úframe_functionz2ImageSequenceClip.__init__.<locals>.frame_function|   sN   ø€ Ù(¨Ó+�à˜DŸO™OÒ+Ü&,¨T¯]©]¸5Ñ-AÓ&BÂ1ÂaÈÈ!ÈÀ8Ñ&L�D”OØ&+�D”Oà—‘Ð&ó    é   é   c                 ó&  •—  ‰| «      }|‰j                   j                  k7  rZt        ‰j                  |   «      d d …d d …df   }|j	                  t
        «      dz  ‰j                   _        |‰j                   _        ‰j                   j                  S )Nr   éÿ   )Úmaskr   r   r   ÚastypeÚfloatr   )r   r   Úframer   r   s      €€r   Úmask_frame_functionz7ImageSequenceClip.__init__.<locals>.mask_frame_functionŠ   ss   ø€ Ù,¨QÓ/�EØ §	¡	× 4Ñ 4Ò4Ü & t§}¡}°UÑ';Ó <ºQÂÀ1¸WÑ E˜Ø/4¯|©|¼EÓ/BÀSÑ/H˜Ÿ	™	Ô,Ø/4˜Ÿ	™	Ô,àŸ9™9×/Ñ/Ð/r   éÿÿÿÿc                 óJ   •—  ‰| «      }‰j                   |   d d …d d …d d…f   S r   ©r   r   s     €€r   r   z2ImageSequenceClip.__init__.<locals>.frame_function˜   s+   ø€ Ù(¨Ó+�Ø—}‘} UÑ+ªAªq°"°1°"¨HÑ5Ð5r   c                 óR   •—  ‰| «      }d‰j                   |   d d …d d …df   z  dz  S )Nr	   r   r!   r)   r   s     €€r   r&   z7ImageSequenceClip.__init__.<locals>.mask_frame_functionŸ   s1   ø€ Ù,¨QÓ/�EØ §¡¨uÑ!5²aº¸A°gÑ!>Ñ>ÀÑDÐDr   )!Ú
ValueErrorr   Ú__init__Ú
isinstanceÚlistÚstrr   ÚsortedÚosÚlistdirÚpathÚjoinÚshapeÚ	ExceptionÚfpsr   r   ÚnpÚfinfoÚfloat32Úepsr   ÚcumsumÚ	durationsÚsumÚdurationÚendr   r   r   r"   r   Úsize)r   r   r7   r=   Ú	with_maskr   Úload_imagesÚ	fromfilesÚfilerA   ÚimageÚimage1r   r   r&   r   s   `              @r   r,   zImageSequenceClip.__init__0   s/  ù€ ð ˆK˜iÐ/ÜÐJÓKÐKÜ×Ñ˜4¨Õ1ð ˆ	ä�h¤Ô%Ü˜( 1™+¤sÔ+ÙØ9AÖB°¤ t¥ÐB�HÐBØ %‘Ià $‘Ið "‘	ð ˆIÜÜ:<¿*¹*ÀXÓ:NÖO°$”—‘—‘˜h¨Õ-ÒOóˆHô
 �h˜q‘k¤3Ô'Ü˜( 1™+Ó&×,Ñ,‰Dà˜A‘;×$Ñ$ˆDàò 	ˆEØˆFÜ˜%¤Ô%Ü ›�Ø�v—|‘|Ó#ÜØXóð ð	ð ˆŒØˆ?Ø08Ö9 u˜˜s›Ð9ˆIÐ9äBGÌÈHËÓBVö"Ø=>��a‘˜#‘¤§¡¬¯©Ó 4× 8Ñ 8Ó8ò"ˆDÕð #$ ¤t¬B¯I©I°iÓ,@Ó'AÑ!AˆDÔØ"ˆŒÜ˜I›ˆŒØ—=‘=ˆŒØ ˆŒàˆ;Ü˜8“} t§}¡}Ñ4ˆDŒHô	ñ
 Ø"ˆDŒOØ"ˆDŒOõ'ò œf T§]¡]°1Ñ%5Ó6×<Ñ<¸QÑ?À1ÒDÜ%¨dÔ3�”	Ø'+�—	‘	Ô$Ø'+�—	‘	Ô$õ0ð ,?�—	‘	Ô(Ù!4°QÓ!7×!=Ñ!=¸b¸qÐ!AÁ$ÀBÀ$Ñ!G�—	‘	•õ6ñ ˜dŸm™m¨AÑ.×4Ñ4°QÑ7¸1Ò<Ü%¨dÔ3�”	õEð ,?�—	‘	Ô(Ù!4°QÓ!7×!=Ñ!=¸b¸qÐ!AÁ$ÀBÀ$Ñ!G�—	‘	”à,ˆÔÙ" 1Ó%×+Ñ+¨B¨QÐ/±°"°Ñ5ˆ�	ùòC  Cùò Pùò( :ùò"s   ÁM>Â'NÅNÅ'=N)NNTFF)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r,   © r   r   r   r      s   „ ñ ðJ ØØØØôw6r   r   )	rK   r1   Únumpyr8   Ú
imageio.v2r   Úmoviepy.video.VideoClipr   r   rL   r   r   ú<module>rP      s&   ðñó 
ã Ý å -ôZ6˜	õ Z6r   