
    W|hx#                         S r SSKrSSKrSSKJr  SSKJr  SSKJr  SSK	J
r
  SSKJrJr   SSKJr  S	r " S
 S\5      rSrS\-   S-   SS\-   S-   S.r SS jr      SS jrg! \ a    S rSr N3f = f)zeImplements ``display_in_notebook``, a function to embed images/videos/audio in the
Jupyter Notebook.
    N)	b64encode)	AudioClip)extensions_dict)ffmpeg_parse_infos)	ImageClip	VideoClip)HTMLTc                       \ rS rSrS rSrg)HTML2   c                 F    [        U R                  UR                  -   5      $ N)r   data)selfothers     ^/home/james-whalen/.local/lib/python3.13/site-packages/moviepy/video/io/display_in_notebook.py__add__HTML2.__add__   s    UZZ/00     N)__name__
__module____qualname____firstlineno__r   __static_attributes__r   r   r   r   r      s    	1r   r   c                     U $ r   r   )contents    r   r   r       s    r   Fz@Sorry, seems like your browser doesn't support HTML5 audio/videozN<audio controls><source %(options)s  src='data:audio/%(ext)s;base64,%(data)s'>z</audio>z:<img %(options)s src='data:image/%(ext)s;base64,%(data)s'>zD<video %(options)ssrc='data:video/%(ext)s;base64,%(data)s' controls>z</video>)audioimagevideoc                     Uc  0 nS[        U R                  5      ;   Ga9  Sn[        U [        5      (       a  US-   nUSS.n[        R
                  " U R                  5      R                  n	UR                  UR                  5        V
Vs0 s H  u  pX;   d  M  X_M     snn
5        U R                  " S&0 UD6  O[        U [        5      (       a.  US-   nUSS	.nUR                  U5        U R                  " S&0 UD6  OM[        U [        5      (       a-  US
-   nSU0nUR                  U5        U R                  " S&0 UD6  O[        S5      e[        U4UUUS.UD6$ U nSR!                  UR                  5        VVs/ s H!  u  p[        U5      < S[        U5      < S3PM#     snn5      n["        R$                  R'                  U5      u  nnUSS nUcM  UR)                  S5      S   R+                  5       nUS:X  a  SnO"U[,        ;   a  [,        U   S   nO[        S5      eUS:X  a+  SSSS.nSR!                  UR/                  5       5      n UU   nUS;   a#  [3        USS9S    nUU:  a  [        S!UU4-  5      e[5        US"5       n[7        UR9                  5       5      R;                  S#5      nSSS5        [<        U   nUWUUS$.-  nU(       a  S%U-  nU$ s  snn
f s  snnf ! [0         a    [        SU-   5      ef = f! , (       d  f       NV= f)'ac  Returns HTML5 code embedding the clip.

Parameters
----------

clip : moviepy.Clip.Clip
  Either a file name, or a clip to preview.
  Either an image, a sound or a video. Clips will actually be
  written to a file and embedded as if a filename was provided.

filetype : str, optional
  One of 'video','image','audio'. If None is given, it is determined
  based on the extension of ``filename``, but this can bug.

maxduration : float, optional
  An error will be raised if the clip's duration is more than the indicated
  value (in seconds), to avoid spoiling the browser's cache and the RAM.

rd_kwargs : dict, optional
  Keyword arguments for the rendering, like ``dict(fps=15, bitrate="50k")``.
  Allow you to give some options to the render process. You can, for
  example, disable the logger bar passing ``dict(logger=None)``.

center : bool, optional
  If true (default), the content will be wrapped in a
  ``<div align=middle>`` HTML container, so the content will be displayed
  at the center.

html_kwargs
  Allow you to give some options, like ``width=260``, ``autoplay=True``,
  ``loop=1`` etc.

Examples
--------
.. code:: python

    from moviepy import *
    # later ...
    html_embed(clip, width=360)
    html_embed(clip.audio)

    clip.write_gif("test.gif")
    html_embed('test.gif')

    clip.save_frame("first_frame.jpeg")
    html_embed("first_frame.jpeg")
NClip__temp__z.pngT)filename	with_maskz.mp4	ultrafast)r$   presetz.mp3r$   z5Unknown class for the clip. Cannot embed and preview.)maxduration	rd_kwargscenter z=''   .gifr   typezNo file type is known for the provided file. Please provide argument `filetype` (one of 'image', 'video', 'sound') to the display_in_notebook function.r    mp4webmogg)r2   r3   ogvzVThis video extension cannot be displayed in the Jupyter Notebook. Allowed extensions: )r   r    )decode_filedurationzThe duration of video %s (%.1f) exceeds the 'maxduration' attribute. You can increase 'maxduration', by passing 'maxduration' parameter to display_in_notebook function. But note that embedding large videos may take all the memory away!rbzutf-8)r   optionsextz<div align=middle>%s</div>r   )str	__class__
isinstancer   inspectgetfullargspec
save_frameargsupdateitemsr   write_videofiler   write_audiofile
ValueError
html_embedjoinospathsplitextsplitlowerr   keys	Exceptionr   openr   readdecode	templates)clipfiletyper(   r)   r*   html_kwargsTEMP_PREFIXr$   kwargsargnameskeyvaluekvr9   namer:   exts_htmltypeallowed_extsr7   filer   templateresults                           r   rG   rG   6   s-   d 	T^^$$ dI&&"V+H"*>F--doo>CCHMM.7oo.?S.?
3?.?S OO%f%i(("V+H"*kBFMM)$  *6*i(("V+H (+FMM)$  *6*TUU
#	

 
 	
 HhhARARATUATSVSV4ATUVG  *ID#
ab'CnnS!"%++-%<HO#&s+F3H0  7 !&veDxx 2 2 45	$C %%%hDA*Mk! X&'	 	 
h	%,,W5 
 "H'#FFF.7M] T2 V0  	9;GH 	( 
	s*   	K
K
9(K
K# )K?#K<?
Lc           
          [         (       d  [        S5      eUc  0 nUb  XES'   Ub  U R                  U5      n [        [	        U 4UUUUS.UD65      $ )aK  Displays clip content in an Jupyter Notebook.

Remarks: If your browser doesn't support HTML5, this should warn you.
If nothing is displayed, maybe your file or filename is wrong.
Important: The media will be physically embedded in the notebook.

Parameters
----------

clip : moviepy.Clip.Clip
  Either the name of a file, or a clip to preview. The clip will actually
  be written to a file and embedded as if a filename was provided.

filetype : str, optional
  One of ``"video"``, ``"image"`` or ``"audio"``. If None is given, it is
  determined based on the extension of ``filename``, but this can bug.

maxduration : float, optional
  An error will be raised if the clip's duration is more than the indicated
  value (in seconds), to avoid spoiling the browser's cache and the RAM.

t : float, optional
  If not None, only the frame at time t will be displayed in the notebook,
  instead of a video of the clip.

fps : int, optional
  Enables to specify an fps, as required for clips whose fps is unknown.

rd_kwargs : dict, optional
  Keyword arguments for the rendering, like ``dict(fps=15, bitrate="50k")``.
  Allow you to give some options to the render process. You can, for
  example, disable the logger bar passing ``dict(logger=None)``.

center : bool, optional
  If true (default), the content will be wrapped in a
  ``<div align=middle>`` HTML container, so the content will be displayed
  at the center.

kwargs
  Allow you to give some options, like ``width=260``, etc. When editing
  looping gifs, a good choice is ``loop=1, autoplay=1``.

Examples
--------

.. code:: python

    from moviepy import *
    # later ...
    clip.display_in_notebook(width=360)
    clip.audio.display_in_notebook()

    clip.write_gif("test.gif")
    display_in_notebook('test.gif')

    clip.save_frame("first_frame.jpeg")
    display_in_notebook("first_frame.jpeg")
z%Only works inside an Jupyter Notebookfps)rU   r(   r*   r)   )ipython_availableImportErrorto_ImageClipr   rG   )rT   rU   r(   tre   r)   r*   rV   s           r   display_in_notebookrj      sw    H ABB	
%}  #	
#	
 	
	 	r   )N<   NT)Nrk   NNNT)__doc__r>   rI   base64r   moviepy.audio.AudioClipr   moviepy.toolsr   moviepy.video.io.ffmpeg_readerr   moviepy.video.VideoClipr   r   IPython.displayr	   rf   r   rg   sorryrS   rG   rj   r   r   r   <module>rt      s     	  - ) = 8$1 1 	K	I
	 	
 J	=?D	EGQ	R	  AEJ^ 
YK   s   A% %A32A3