
    i	                     d    d Z ddlZddlZddlZddlmZ ddlmZ d
dZ	ddZ
	 	 	 ddZddZd	 Zy)z* Misc. bindings to ffmpeg and ImageMagick.    N)get_setting)subprocess_callc                     dd|z  z   dz   }t        d      ddddd	|z  d
t        j                  j                  ||      dz   |z   dd|z  dd	|z  | g}t	        |       y)z^
    Writes a movie out of the frames (picture files) in a folder.
    Almost deprecated.
    %z%02dzd.pngFFMPEG_BINARY-yz-fimage2z-r%d-i/z-b%dkN)r   ospathjoinr   )filenamefolderfpsdigitsbitratescmds          [/var/www/html/eduruby.in/venv/lib/python3.12/site-packages/moviepy/video/io/ffmpeg_tools.pyffmpeg_movie_from_framesr      sr    
 	fvo'A'tH48277<<v.4q85=48C C    c                    t         j                  j                  |       \  }}|s*||fD cg c]  }t        d|z         c}\  }}d||||fz  }t	        d      ddd|z  d| dd||z
  z  d	d
dddd|g}	t        |	       yc c}w )ze Makes a new video file playing video file ``filename`` between
        the times ``t1`` and ``t2``. i  z%sSUB%d_%d.%sr   r   z-ssz%0.2fr   z-tz-map0-vcodeccopy-acodecN)r   r   splitextintr   r   )
r   t1t2
targetnamenameexttT1T2r   s
             r   ffmpeg_extract_subclipr*      s       *ID#(*Bx0!#d1f+0B$b"c'::
''"*"R%3	69fj	JC C 1s   A>c                 J    t        d      dd|d| d|d||g}t        ||       y)z^ merges video file ``video`` and audio file ``audio`` into one
        movie file ``output``. r   r   r   r   r   )loggerNr   r   )videoaudiooutputvcodecacodecffmpeg_outputr,   r   s           r   ffmpeg_merge_video_audior4   ,   s4    
 'tU4	66;C C&)r   c           	      N    t        d      dd| dd|z  dd|z  |g	}t        |       y)	z? extract the sound from a video file and save it in ``output`` r   r   r   z-abr   z-arr
   Nr-   )	inputfiler0   r   r   r   s        r   ffmpeg_extract_audior7   7   s2    'tYuW}	S&"CCr   c                 R    t        d      d| dd|d   |d   fz  |g}t        |       y)zY resizes ``video`` to new size ``size`` and write the result
        in file ``output``. r   r   z-vfzscale=%d:%dr      Nr-   )r.   r0   sizer   s       r   ffmpeg_resizer;   >   s>     o
&eUM4PQ7TXYZT[J\<\
C Cr   )   v)N)r   r   Fbar)i  iD  )__doc__r   
subprocessspsysmoviepy.configr   moviepy.toolsr   r   r*   r4   r7   r;    r   r   <module>rF      s;    0 	  
 & ) " 9?:?&+*r   