0

I would like to call a FFmpeg command, which produces a very big output.

I need to store the output in order to make a regex on it.

On the first command (echo), nothing is printed in my terminal, but for the ffmpeg command, huge output is produced (which I want to store in a variable, I don't want to have the output in my terminal)

So my code looks like this for example:

import subprocess
output = subprocess.check_output("echo a lot of wooooords")
output = subprocess.check_output("ffmpeg -i audio.mp3 -f null -", shell=True)

Is it possible to hide the output for this command? Why does it show me an output? Thank you

Dev01
  • 1
  • 1
  • 1
    The output may be to stderr. Try adding `stderr=subprocess.STDOUT` as a parameter. That will send both stdout and stderr to stdout. – tdelaney Jul 06 '22 at 23:01
  • s/may be/is quite certainly/ – Charles Duffy Jul 06 '22 at 23:16
  • BTW, `shell=True` is a bad idea here, _especially_ if the `audio.mp3` file name isn't hardcoded. Consider using `['ffmpeg', '-i', 'audio.mp3', '-f', 'null', '-']` with the default `shell=False` so you can replace `audio.mp3` with a variable without incurring security bugs. – Charles Duffy Jul 06 '22 at 23:19
  • you can pass `-loglevel quiet` to FFmpeg – AudioBaton Jul 07 '22 at 17:04

0 Answers0