I have an issue
I want to create a new ffmpeg process using subprocess.popen find out his pid and in the body of a python program to see if the process is alive or not
args = shlex.split ('ffmpeg -i rtsp: //192.168.1.68: 8554 / mystream -f segment -strftime 1 -segment_time 5 13_REG1_CHANNEL3_% Y-% m-% d_% H-% M-% S-% s .mp3 ')
print (args)
proc = subprocess.Popen (args, stdout = subprocess.PIPE)
ch_pid = proc.pid
print (proc.pid)
proc.wait ()
print (proc.communicate ())
while (1):
if (os.system (str ('kill -0 {PID}'). format (PID = ch_pid)) == 0):
print ('proc is alive')
else:
break
at while loop i tried to check this process pid via kill -0 pid this command will return zero if everything is alright and process is running
BUT
IF ffmpeg will fall there will be no changes
kill -0 pid will continue to returning zero code that everything is good
What should i do?