
    i                     T    d dl Z d dlZd dlZd dlmZ d dlmZ  e       Zd Zd Z	d Z
y)    N)get_ffprobe_path)Consolec                 |   t               dddddd| g}t        j                  |ddd	      }|j                  d
k7  rt	        j
                  d|j                          t	        j
                  d|j                          t	        j
                  d|j                          t	        j
                  ddj                  |              yt        j                  |j                        }|j                  di       j                  d      |j                  dg       D cg c]  }|j                  d       c}dS c c}w )a7  
    Get format and codec information for a media file using ffprobe.

    Parameters:
        - file_path (str): Path to the media file.
    
    Returns:
        dict: A dictionary containing the format name and a list of codec names.
              Returns None if file does not exist or ffprobe crashes.
    z-verrorz-show_formatz-show_streamsz-print_formatjsonTF)capture_outputtextcheckr   z FFprobe failed with return code zFFprobe stderr: zFFprobe stdout: z	Command:  Nformatformat_namestreams
codec_name)r   codec_names)r   
subprocessrun
returncodeloggingr   stderrstdoutjoinr   loadsget)	file_pathcmdresultinfostreams        g/home/nidran/Documenti/script/streaming-community/StreamingCommunity/core/processors/helper/ex_video.pyget_ffprobe_infor       s    tWno`fhq
rC^^C4uMFA89J9J8KLM(89(89	#((3-12 ::fmm$Dxx"-11-@?Cxx	SU?VWV

<0W Ws   D9c                 \    | sy| j                  d      dk(  xs d| j                  dg       v S )a  
    Check if the format is 'png_pipe' or if any codec is 'png'.

    Parameters:
        - file_info (dict): The dictionary containing file information.

    Returns:
        bool: True if the format is 'png_pipe' or any codec is 'png', otherwise False.
    Fr   png_pipepngr   )r   )	file_infos    r   is_png_format_or_codecr%   3   s5     ==':5b)--P]_aBb9bb    c                 .    t        t        |             ryy)z
    Get if a file to TS format if it is in PNG format or contains a PNG codec.

    Parameters:
        - file_path (str): Path to the input media file.
    TF)r%   r    )r   s    r   need_to_force_to_tsr(   C   s     .y9:r&   )r   r   r   StreamingCommunity.setupr   rich.consoler   consoler    r%   r(    r&   r   <module>r-      s3       6 ! )>c 
r&   