Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

subprocess.call() in Python

senmeis

Full Member level 2
Joined
Nov 26, 2014
Messages
149
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,296
Activity points
2,386
Hi,

I want to use

Python:
subprocess.call(["ffmpeg", "-i", "test.mp4", "test.mp3"])

to make a media conversion.

Question: how can I redirect the console output so that this can be outputted with „print()“?
 

senmeis

Full Member level 2
Joined
Nov 26, 2014
Messages
149
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,296
Activity points
2,386
I tried the following two alternatives:



Alternative 1:

Python:
out = subprocess.run(["ffmpeg", "-i", "test.mp4", "test.mp3"], capture_output=True, text=True, shell=True)
print(out.stdout)



Alternative 2:

Python:
out = subprocess.check_output(["ffmpeg", "-i", "test.mp4", "test.mp3"], shell=True)
print(out.decode('utf-8'))


but both don’t print out anything. I just want to get the process info which comes from the console when ffmpeg is executed.
 

LaTeX Commands Quick-Menu:

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Top