Python-ffmpeg(开始、停止录制的命令)

Python-ffmpeg(开始、停止录制的命令),python,cmd,ffmpeg,command,Python,Cmd,Ffmpeg,Command,我需要一个程序,将打开cmd,并有一个命令开始记录在cmd和停止记录在cmd import win32com.client from datetime import datetime import time shell = win32com.client.Dispatch("WScript.Shell") shell.run("cmd") #run's command panel shell.AppActivate("cmd") time.sleep(3) #wait's 3 seconds

我需要一个程序,将打开cmd,并有一个命令开始记录在cmd和停止记录在cmd

import win32com.client
from datetime import datetime
import time

shell = win32com.client.Dispatch("WScript.Shell")
shell.run("cmd") #run's command panel
shell.AppActivate("cmd")
time.sleep(3) #wait's 3 seconds
shell.SendKeys('ffmpeg -y -f dshow -i video="Logitech HD Webcam C270"  
kamera.mp4') #type's in cmd the following (start's recording)
time.sleep(3)
shell.SendKeys("{ENTER}") #enter is pressed in cmd
time.sleep(6)
shell.SendKeys('exit')
shell.SendKeys("{ENTER}") #here is a problem, the proggrame wont shutdown after 6 sec

我可以在ffmpeg中使用-t 00:00:03,但我需要通过命令关闭程序

我已经自己破解了,如果有人需要代码,它是:

import win32com.client
from datetime import datetime
import time

datestring = datetime.strftime(datetime.now(), '%Y-%m-%d-%H-%M-%S')
shell = win32com.client.Dispatch("WScript.Shell")

shell.run("cmd")
shell.AppActivate("cmd")

#shell.run('ffmpeg -y -f dshow -i video="Logitech HD Webcam C270"  kamera' + datestring + '.mp4')
time.sleep(2)
shell.SendKeys('ffmpeg -y -f dshow -i video="Logitech HD Webcam C270"  kamera.mp4')
time.sleep(2)
shell.SendKeys("{ENTER}")
time.sleep(10)
shell.SendKeys('^c')
time.sleep(2)
shell.SendKeys("{ENTER}")