所有内容似乎都写入了我的avi文件output.avi(它比我启动程序之前大),但由于错误0xc10100be,我无法打开它。我将如何尝试使文件可读?另外,我对python有相当的经验,但是openCV对我来说是新的。
提前谢谢! 代码:
import psutil
import time
import cv2
import wx
import pyautogui
import numpy as np
import subprocess as sp
running = True
while True:
if "League of Legends (TM) Client" in (p.name() for p in psutil.process_iter()):
app = wx.App(False)
SCREEN_SIZE = wx.GetDisplaySize()
SCREEN_SIZE = tuple(SCREEN_SIZE)
fourcc = cv2.VideoWriter_fourcc('M', 'J', 'P', 'G')
out = cv2.VideoWriter("output.avi", fourcc, 20.0, SCREEN_SIZE)
ffmpeg = 'FFMPEG'
dimension = '{}x{}'.format(SCREEN_SIZE[0], SCREEN_SIZE[1])
f_format = 'bgr24'
fps = str(out.get(cv2.CAP_PROP_FPS))
command = [ffmpeg,
'-y',
'-f', 'rawvideo',
'-vcodec', 'rawvideo',
'-s', dimension,
'-pix_fmt', 'bgr24',
'-r', fps,
'-i', '-',
'-an',
'-vcodec', 'mpeg4',
'-b:v', '5000k',
"output.avi"]
proc = sp.Popen(command, stdin=sp.PIPE, stderr=sp.PIPE)
while True:
img = pyautogui.screenshot()
frame = np.array(img)
frame = cv2.cvtColor(frame, cv2.COLOR_BGR2RGB)
out.write(frame)
time.sleep(5)
cv2.destroyAllWindows
out.release()