Search code examples
pythonprocessmediainfo

How do I suppress the output in subprocess.call, but save the output?


At the moment the code I have is

print ("Getting MediaInfo...")
mediainfo_command = ("mediainfo", input_file_full)
mediainfo = (subprocess.call(mediainfo_command))

So what I want to do is save the output of the subprocess.call into the variable mediainfo. But I don't want to display the actual output of the command in the terminal.

Is this possible?


Solution

  • You may also want to look at subprocess.check_output.

    print ("Getting MediaInfo...")
    mediainfo_command = ["mediainfo", input_file_full]
    mediainfo = subprocess.check_output(mediainfo_command)