I am attempting to run the following code in a python app executable made using
pyinstaller -w -F script.py
:
def ffmpeg_command(sec):
cmd1 = ['ffmpeg', '-f','gdigrab','-framerate',config.get('FFMPEG_Settings','Framerate'),'-i','desktop',gen_filename_from_timestamp_and_extension()]
proc = subprocess.Popen(cmd1,stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
duration = sec
sleeptime = 0
while proc.poll() is None and sleeptime < duration:
# Wait for the specific duration or for the process to finish
time.sleep(1)
sleeptime += 1
proc.terminate()
The above code is run when a Tkinter button is pressed and this code is called from the button click handler.
My problem is that when I am running the exe this doesn't run ffmpeg. However, If I set the command to be:
proc = subprocess.Popen(cmd1)
FFMPEG does run, I get the movie file I wanted but I can see the console window for FFMPEG. So I end up getting the console window in my movie. (I take care of minimizing the Tkinter window in the button click handler)
My question is how do I suppress the console window and still have FFMPEG run the way I want it to? I looked at the following threads but couldn't make it work: How to hide output of subprocess in Python 2.7, Open a program with python minimized or hidden
Thank you