Question

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?

Was it helpful?

Solution 2

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)

OTHER TIPS

Use subprocess.Popen.communicate instead.

print ("Getting MediaInfo...")
mediainfo_command = ["mediainfo", input_file_full]
proc = subprocess.Popen(mediainfo_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
mediainfo, mediaerr = proc.communicate()
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top