0

How do I execute the following linux command line command using Python

mplayer -identify -frames 0 -vo null -nosound metallica.mp4 2>&1 | awk -F= '/LENGTH/{print $2}'

I tried

p1 = subprocess.Popen(["mplayer","-identify","-frames","0","-vo","null","-nosound","test1.mp4","2>&1"], stdout=subprocess.PIPE)
p2 = subprocess.Popen(["awk","-F","'/LENGTH/{print $2}'"], stdin=p1.stdout, stdout=subprocess.PIPE)
p2.communicate()

I am getting the following error for the above

mplayer: could not connect to socket mplayer: No such file or directory Failed to open LIRC support. You will not be able to use your remote control.

Kindly help

1 Answers1

0
import subprocess

cmdline = "mplayer -identify -frames 0 -vo null -nosound metallica.mp4 2>&1 | awk -F= '/LENGTH/{print $2}'"
p1 = subprocess.Popen(cmdline, shell=True, stdout=subprocess.PIPE)
print(p1.communicate())
Stephane Martin
  • 1,612
  • 1
  • 17
  • 25