Wait subprocess.run until completes its task
subprocess.run() is synchronous which means that the system will wait till it finishes before moving on to the next command. subprocess.Popen() does the same thing but it is asynchronous (the system will not wait for it to finish). You can try reloading your file using importlib.reload command. It may find your generated file then.
According to the python documentation subprocess.run
waits for the process to end.
The problem is that ffmpeg
overwrites the input file if the input and output files are the same and therefore the output video becomes unusable.