I want to use ffmpeg to capture videos and the timing will end automatically. I am a novice and the command is not complicated. I just use subprocess.Popen to start the ffmpeng command to capture the video and save it as mp4. I have tested it under cmd. The command There is no problem, and the test can also be recorded using python. The problem is that it cannot be ended. . I used subprocess.kill to end the process, but it only ended cmd. ffmpeg started by cmd still continued to work. I don't know how to end the process it generated. . .
cmd = '''ffmpeg1.exe -i "rtmp://123.123.123.132/live/tv22 live=1" -acodec libmp3lame -vcodec libx264 -y 3.mkv''' cc=subprocess.Popen(cmd2,shell=True) print(cc.pid) time.sleep(15) cc.terminate()
You can’t end it with terminat or kill. You can only end the cmd process. The generated ffmpeg1.exe process cannot be stopped.
If there is a termination method that imitates ctrl c, please help.
I later tested ping 127.0.0.1 and found that cmd could be terminated but ping.exe could not be terminated
Um... I just saw a duplicate question, so I'll copy the answer...
Try to kill directly using the
windows
command