Python新开的一个控制台执行cmd命令

import os
import time
import subprocess

def get_cmd():
    commands = []
    cmd = "ffmpeg -re -i ./%d_0.mp4 -r 25 -vcodec copy -f flv rtmp://localhost:1935/free-view/camera%d"
    for i in range(1, 31):
        tmp_cmd = cmd % (i, i)
        commands.append(tmp_cmd)
    return commands

if __name__ == '__main__':
    commands = get_cmd()
    for i in range(1, 30):
        subprocess.Popen(commands[i], creationflags=subprocess.CREATE_NEW_CONSOLE)
        time.sleep(0.05)

    while(int(input("输入9,关键子进程")) != 9):
        print("重新输入")

    os.system("taskkill /IM ffmpeg.exe /F")

你可能感兴趣的:(Python)