I'm trying to capture the output of a command with the following code:
lines = subprocess.run(['ffmpeg', '-hide_banner', '-nostats', '-i', in_filename, '-vn', '-af', 'silencedetect=n={}:d={}'.format(silence_threshold, silence_duration), '-f', 'null', '-'], capture_output=True, text=True, shell=True, check=True, encoding='utf-8').stdout
print (lines)
But lines is an empty string and nothing is printed.
When capture_output=True
is removed, the correct output is showed (without printing it).
I tested many combinations, including removing all the subprocess.run
parameters and only include capture_output=True
with the same result.
I also tested with few argument for a minimal example: subprocess.run(['ffmpeg', '-version'], capture_output=True, text=True, shell=True, check=True, encoding='utf-8').stdout
Also tested stdout=subprocess.PIPE
and stderr=subprocess.PIPE
as subprocess.run
arguments instead of capture_output=True
I can't figure out what is happening. Thanks in advance!