Checking if subprocess was terminated by user

39 views Asked by At
# Create a new terminal window and run the ffmpeg command in it
cmd = ' '.join(ffmpeg.compile(output_stream, overwrite_output=True))
compressing = subprocess.Popen('start cmd /k {}'.format(cmd), shell=True)

while compressing.poll() is None: #check if the process is still running
    print('Processing video...')
    break
else:
    if compressing.returncode == 0: #check if the process was canceled by the user
       print('Video processing canceled by user!')
    else: #if the process was completed successfully
        print('Video processing complete!')

I want to check if the process (terminal) was closed by the user it should print that sentence, however it's always stuck at "Processing Video" even if the user kills the subprocess terminal

0

There are 0 answers