
    9i                         d dl Z d dlZd dlZd dlZd dlmZ d dlZddlm	Z	m
Z
  e j        d          Zd Z e            d             Zd Zdd
Zd Zd ZdS )    N)	lru_cache   )FNAME_PER_PLATFORMget_platformimageio_ffmpegc                  v    t          j        dd          } | r| S t                      } | r| S t          d          )a=  
    Get the ffmpeg executable file. This can be the binary defined by
    the IMAGEIO_FFMPEG_EXE environment variable, the binary distributed
    with imageio-ffmpeg, an ffmpeg binary installed with conda, or the
    system ffmpeg (in that order). A RuntimeError is raised if no valid
    ffmpeg could be found.
    IMAGEIO_FFMPEG_EXENzpNo ffmpeg exe could be found. Install ffmpeg on your system, or set the IMAGEIO_FFMPEG_EXE environment variable.)osgetenv_get_ffmpeg_exeRuntimeError)exes    ZC:\Users\betacode\Desktop\descargarYoutube\venv\Lib\site-packages\imageio_ffmpeg/_utils.pyget_ffmpeg_exer      sV     )($
/
/C
 
 

C
 
 	>      c                  h   t                      } t          j                            t	                      t          j        | d                    }|r0t          j                            |          rt          |          r|S | 	                    d          r-t          j                            t          j        ddd          }n+t          j                            t          j        dd          }|r0t          j                            |          rt          |          r|S d}t          |          r|S d S )N winLibrarybinz
ffmpeg.exeffmpeg)r   r
   pathjoin_get_bin_dirr   getisfile_is_valid_exe
startswithsysprefix)platr   s     r   r   r   '   s   >>D ',,|~~'9'=dB'G'G
H
HC
 rw~~c"" }S'9'9 
 u 8gll3:y%FFgll3:uh77
 rw~~c"" }S'9'9 
 CS 
4r   c                  D   t           j        dk     r!t          j                            dd          } nAt          j                            d          dz  }t          j                            |          } | 5 }	 d d d            n# 1 swxY w Y   t          |j                  S )N)   	   zimageio_ffmpeg.binariesz__init__.py)	r   version_info	importlib	resourcesr   filesas_filestrparent)contextrefr   s      r   r   r   A   s    
&  %**+DmTT!''(ABB]R%--c22	 D               t{s   5BB
BFc                 l   d }d }d}t           j                            d          r-t          j                    }|xj        t          j        z  c_        | r.t           j                            d          rd}nt          j        }d}t          j	        dd          
                                |vrd }|||dS )Nr   r   i   )r   0falseno IMAGEIO_FFMPEG_NO_PREVENT_SIGINTr   )startupinfocreationflags
preexec_fn)r   platformr   
subprocessSTARTUPINFOdwFlagsSTARTF_USESHOWWINDOWr
   setpgrpr   lower)prevent_sigintr3   r5   r4   falsys        r   _popen_kwargsr?   M   s    KJM
|u%% ? ,..z>> $ <""5)) 	$&MMJ$E	y3R88>>@@MM
 #&   r   c                    | dg}	 t          t          j        d          5 }t          j        |f|t          j        dt                       d d d            n# 1 swxY w Y   dS # t          t          t          j	        f$ r Y dS w xY w)N-versionw)stdoutstderrTF)
openr
   devnullr7   
check_callSTDOUTr?   OSError
ValueErrorCalledProcessError)r   cmdnulls      r   r   r   i   s    

C"*c"" 	d! ): >Koo  	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 tZ!>?   uus4   A% ,AA% AA% A A% %BBc                     t                      } t          j        | dgfi t                                          dd          d         }|                    d                                          }|                    dd          d                                                             d	d          d                                         }|S )
zF
    Get the version of the used ffmpeg executable (as a string).
    rA      
r   r   ignore)errorsversion )r   r7   check_outputr?   splitdecodestriplstrip)r   linerR   s      r   get_ffmpeg_versionr[   u   s     

C"C#4HHHHNNq 	D ;;h;''--//DjjA&&r*113399#qAA!DJJLLGNr   )F)loggingr
   r7   r   	functoolsr   importlib.resourcesr&   _definitionsr   r   	getLoggerloggerr   r   r   r?   r   r[    r   r   <module>rc      s     				     



           : : : : : : : :		+	,	,  4   2	 	 	   8	 	 	
 
 
 
 
r   