请参见以下代码:
,并且可以通过exe(编解码器XVID,在视频刻录机中格式化avi)创建avi。因此,在带有mp4视频的pyinstaller中似乎有问题吗?
import tkinter as tk
import cv2
import numpy as np
from PIL import ImageGrab
window = tk.Tk()
window.title('Basic Camera App2')
window.geometry('350x250')
def StartS():
fourcc = cv2.VideoWriter_fourcc(*'DIVX')
vid=cv2.VideoWriter(r"C:\\IQOutput\\123.mp4", fourcc, 12, (1270,710))
while(True):
img = ImageGrab.grab(bbox=(10,10,1280,720))
img_np=np.array(img)
frame=cv2.cvtColor(img_np, cv2.COLOR_BGR2RGB)
vid.write(frame)
cv2.imshow("frame", frame)
key=cv2.waitKey(1)
if key==27:
break
vid.release()
cv2.destroyAllWindows()
bstarts = tk.Button(window, text='RecScr', font=('Arial', 8), bg='light
pink', width=5, height=1, command=StartS)
bstarts.place(x=130, y=10, anchor='nw')
window.mainloop()