python - Using ffmpeg to capture video, the process cannot be ended using terminate
曾经蜡笔没有小新
曾经蜡笔没有小新 2017-06-14 10:51:23
0
1
1169

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

曾经蜡笔没有小新
曾经蜡笔没有小新

reply all(1)
扔个三星炸死你

Um... I just saw a duplicate question, so I'll copy the answer...

Try to kill directly using the windows command

kill_command = 'taskkill -f ffmpeg1.exe'
cc=subprocess.Popen(kill_command ,shell=True)
....(自己补充)
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template