With the following command, it prints '640x360'
>>> command = subprocess.call(['mediainfo', '--Inform=Video;%Width%x%Height%',
'/Users/Desktop/1video.mp4'])
640x360
How would I set a variable equal to the string of the output, so I can get x='640x360'
? Thank you.
If you're using 2.7, you can use subprocess.check_output():
>>> import subprocess
>>> output = subprocess.check_output(['echo', '640x360'])
>>> print output
640x360
If not:
>>> p = subprocess.Popen(['echo', '640x360'], stdout=subprocess.PIPE)
>>> p.communicate()
('640x360\n', None)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With