3

i have a problem with ffmpeg when i run it in the cmd i havethe correct output "ffprobe passionfruit.mp4 -show_streams"

But when i use the same with subprocess :

command = 'ffprobe "C:/Users/NMASLORZ/Downloads/passionfruit.mp4" -show_streams'
p = subprocess.Popen(command, universal_newlines=True, shell=True,stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
text = p.stdout.read()
retcode = p.wait()
print (text)

i have this output : "'ffprobe' is not recognized as an internal command or external, an executable program or a batch file." i tried every synthax and even in a list i still have the same output

1 Answers1

5

That's because your Windows terminal reads system's PATH or has otherwise defined path to the ffprobe. When you run Popen with shell=True it runs the execution through shell that might or might not (your case) have access to that PATH.

Possible solutions:

  1. Provide full path to ffprobe (easiest):
command = 'C:\whatever\ffprobe.exe "C:/Users/NMASLORZ/Downloads/passionfruit.mp4" -show_streams'
  1. Use shell=False. Might not work, depends on your system.
command = ('ffprobe', 'C:/Users/NMASLORZ/Downloads/passionfruit.mp4', '-show_streams')
p = subprocess.Popen(command, universal_newlines=True, shell=False,stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
  1. Add PATH through env variable and in that PATH add ffprobe.

If env is not None, it must be a mapping that defines the environment variables for the new process; these are used instead of the default behavior of inheriting the current process’ environment. It is passed directly to Popen.

Check the docs for further guidance.

Lukasz Tracewski
  • 10,794
  • 3
  • 34
  • 53