[Python] How can I run FFPROBE in a Python script without triggering the Windows Command...

Discussão em 'Python' iniciado por Stack, Março 1, 2025.

  1. Stack

    Stack Membro Participativo

    I am using ffmeg/ffprobe to get video durations (in an addon for Kodi). The code:

    result = subprocess.run(["ffprobe", "-hide_banner", "-v", "quiet", "-show_entries",
    "format=duration", "-of",
    "default=noprint_wrappers=1:nokey=1", filename], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)


    The above code and the file importing that code both have a .pyw extension (after first trying regular .py).

    This works fine but in Windows 11 it causes the black Windows Command window to briefly flash for each video, despite the -hide_banner flag and loglevel being set to quiet. In Linux Mint it runs without any such window popping up.

    Found the answer: subprocess.run just needed a final shell=True as the last argument.

    Continue reading...

Compartilhe esta Página