Reputation: 21
I am trying to run a command using os
or subproccess
module in python. the command prompt window briefly flickers before terminating. Is there a way of eliminating that popping up of command prompt window..?
For example:
os.system("ffmpeg -i output.wav output.flac")
Is there a way I can run this in the background so that user may not notice this..?
I am running windows 7 with python 2.7.
Upvotes: 2
Views: 4972
Reputation: 5559
def asyncRun(command):
os.system(command)
t = Thread(target=asyncRun, args=('ping 127.0.0.1 -s 271',))
t.start()
works on windows 10 + EMET + 2.7
Upvotes: 0
Reputation: 41247
The easiest thing would be to try to take advantage of the subproccess
modules partial support for the STARTUPINFO
structure. Something like this:
info = subprocess.STARTUP_INFO()
info.dwFlags = subprocess.STARTF_USESTDHANDLES | subprocess.STARTF_USESHOWWINDOW
info.wShowWindow = subprocess.SW_HIDE
process = subprocess.Popen("ffmpeg -i output.wav output.flac", startupinfo=info)
process.wait()
Upvotes: 1
Reputation: 113930
of coarse ... you even tagged it with the module you would use ...
subproccess.Popen("ffmpeg -i output.wav output.flac".split(),shell=True).communicate()
should do it ...
Upvotes: 0