platypush.plugins.ffmpeg

class platypush.plugins.ffmpeg.FfmpegPlugin(ffmpeg_cmd: str = 'ffmpeg', ffprobe_cmd: str = 'ffprobe', **kwargs)[source]

Generic FFmpeg plugin to interact with media files and devices.

Requires:

  • ffmpeg-python (pip install ffmpeg-python)

  • The ffmpeg package installed on the system.

__init__(ffmpeg_cmd: str = 'ffmpeg', ffprobe_cmd: str = 'ffprobe', **kwargs)[source]

Initialize self. See help(type(self)) for accurate signature.

info(filename: str, **kwargs)dict[source]

Get the information of a media file.

Parameters

filename – Path to the media file.

Returns

Media file information. Example:

  {
    "streams": [
        {
            "index": 0,
            "codec_name": "h264",
            "codec_long_name": "H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10",
            "profile": "High 4:2:2",
            "codec_type": "video",
            "codec_time_base": "1/60",
            "codec_tag_string": "[0][0][0][0]",
            "codec_tag": "0x0000",
            "width": 640,
            "height": 480,
            "coded_width": 640,
            "coded_height": 480,
            "closed_captions": 0,
            "has_b_frames": 2,
            "pix_fmt": "yuv422p",
            "level": 30,
            "chroma_location": "left",
            "field_order": "progressive",
            "refs": 1,
            "is_avc": "true",
            "nal_length_size": "4",
            "r_frame_rate": "30/1",
            "avg_frame_rate": "30/1",
            "time_base": "1/1000",
            "start_pts": 0,
            "start_time": "0.000000",
            "bits_per_raw_sample": "8",
            "disposition": {
                "default": 1,
                "dub": 0,
                "original": 0,
                "comment": 0,
                "lyrics": 0,
                "karaoke": 0,
                "forced": 0,
                "hearing_impaired": 0,
                "visual_impaired": 0,
                "clean_effects": 0,
                "attached_pic": 0,
                "timed_thumbnails": 0
            },
            "tags": {
                "ENCODER": "Lavc58.91.100 libx264"
            }
        }
    ],
    "format": {
        "filename": "./output.mkv",
        "nb_streams": 1,
        "nb_programs": 0,
        "format_name": "matroska,webm",
        "format_long_name": "Matroska / WebM",
        "start_time": "0.000000",
        "size": "786432",
        "probe_score": 100,
        "tags": {
            "ENCODER": "Lavf58.45.100"
        }
    }
}